From 25c76c67cea8bfa105aeeb5cd1e87e3a44dbdcb6 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Sun, 1 Oct 2023 16:06:40 -0700 Subject: [PATCH] updating --- stage2/include/colors.h | 11 +++++++++ stage2/src/main.cc | 26 +++++++++++++++++++ ulisp/include/colors.h | 11 +++++++++ ulisp/platformio.ini | 12 ++++++++- ulisp/src/ulisp.cc | 55 +++++++++++++++++++---------------------- 5 files changed, 85 insertions(+), 30 deletions(-) create mode 100644 stage2/include/colors.h create mode 100644 ulisp/include/colors.h diff --git a/stage2/include/colors.h b/stage2/include/colors.h new file mode 100644 index 0000000..47268ee --- /dev/null +++ b/stage2/include/colors.h @@ -0,0 +1,11 @@ +#pragma once + +// Color definitions +#define BLACK 0x0000 +#define BLUE 0x001F +#define RED 0xF800 +#define GREEN 0x07E0 +#define CYAN 0x07FF +#define MAGENTA 0xF81F +#define YELLOW 0xFFE0 +#define WHITE 0xFFFF \ No newline at end of file diff --git a/stage2/src/main.cc b/stage2/src/main.cc index f4e6810..c4cb49a 100644 --- a/stage2/src/main.cc +++ b/stage2/src/main.cc @@ -1,5 +1,16 @@ #include +#include +#include +#include +#include "colors.h" + +#define TFT_CS 9 +#define TFT_DC 10 +#define BACKGROUND_COLOR 0xDEFB +#define FOREGROUND_COLOR BLACK + +Adafruit_ILI9341 tft(TFT_CS, TFT_DC); Adafruit_NeoPixel pixels(1, 11, NEO_GRB + NEO_KHZ800); auto cOff = pixels.Color(0, 0, 0); @@ -15,6 +26,19 @@ setup() pixels.begin(); pixels.clear(); pixels.show(); + + tft.begin(); + tft.setRotation(1); + tft.setTextSize(1); + tft.setCursor(0, 8); + + tft.fillScreen(BACKGROUND_COLOR); + tft.setTextColor(FOREGROUND_COLOR); + + tft.println(" \\ (define square (x) (* x ))"); + tft.println(" \\ (square 3)"); + tft.println(" 9"); + tft.println(" \\ "); } @@ -50,6 +74,7 @@ pixelOn(uint32_t c) pixels.show(); } + void pixelOff() { @@ -64,4 +89,5 @@ loop() static bool on = false; on = blink(on); + delayMicroseconds(100); } diff --git a/ulisp/include/colors.h b/ulisp/include/colors.h new file mode 100644 index 0000000..47268ee --- /dev/null +++ b/ulisp/include/colors.h @@ -0,0 +1,11 @@ +#pragma once + +// Color definitions +#define BLACK 0x0000 +#define BLUE 0x001F +#define RED 0xF800 +#define GREEN 0x07E0 +#define CYAN 0x07FF +#define MAGENTA 0xF81F +#define YELLOW 0xFFE0 +#define WHITE 0xFFFF \ No newline at end of file diff --git a/ulisp/platformio.ini b/ulisp/platformio.ini index 03a8d3e..d3108fc 100644 --- a/ulisp/platformio.ini +++ b/ulisp/platformio.ini @@ -16,7 +16,17 @@ build_cache_dir = ~/.platformio/work/cache [env] platform = atmelsam framework = arduino -lib_deps = arduino-libraries/SD +lib_deps = + adafruit/Adafruit BusIO @ ^1.7.1 + adafruit/Adafruit GFX Library @ ^1.10.4 + adafruit/Adafruit ILI9341 @ ^1.5.6 + adafruit/Adafruit NeoPixel @ ^1.7.0 + adafruit/Adafruit Zero DMA Library @ ^1.0.8 + adafruit/RTClib @ ^1.12.4 + arduino-libraries/SD @ ^1.2.4 + arturo182/BBQ10Keyboard + SPI + Wire [env:adafruit_feather_m4] board = adafruit_feather_m4 diff --git a/ulisp/src/ulisp.cc b/ulisp/src/ulisp.cc index a9cd616..1a2fe87 100644 --- a/ulisp/src/ulisp.cc +++ b/ulisp/src/ulisp.cc @@ -15,7 +15,7 @@ const char LispLibrary[] PROGMEM = ""; #define printfreespace // #define printgcs #define sdcardsupport -// #define gfxsupport +#define gfxsupport // #define lisplibrary #define assemblerlist // #define lineeditor @@ -31,18 +31,15 @@ const char LispLibrary[] PROGMEM = ""; #if defined(gfxsupport) #include // Core graphics library -#include // Hardware-specific library for ST7735 -#define COLOR_WHITE 0xffff -#define COLOR_BLACK 0 +// #include // Hardware-specific library for ST7735 +#include +#include "colors.h" +#define BACKGROUND_COLOR 0xDEFB +#define FOREGROUND_COLOR BLACK -// Adafruit PyBadge/PyGamer -#define TFT_CS 44 // Chip select -#define TFT_RST 46 // Display reset -#define TFT_DC 45 // Display data/command select -#define TFT_BACKLIGHT 47 // Display backlight pin -#define TFT_MOSI 41 // Data out -#define TFT_SCLK 42 // Clock out -Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST); +#define TFT_CS 9 +#define TFT_DC 10 +Adafruit_ILI9341 tft(TFT_CS, TFT_DC); #endif #if defined(sdcardsupport) @@ -4187,7 +4184,7 @@ object *fn_listlibrary (object *args, object *env) { object *fn_drawpixel (object *args, object *env) { #if defined(gfxsupport) (void) env; - uint16_t colour = COLOR_WHITE; + uint16_t colour = FOREGROUND_COLOR; if (cddr(args) != NULL) colour = checkinteger(DRAWPIXEL, third(args)); tft.drawPixel(checkinteger(DRAWPIXEL, first(args)), checkinteger(DRAWPIXEL, second(args)), colour); #endif @@ -4197,7 +4194,7 @@ object *fn_drawpixel (object *args, object *env) { object *fn_drawline (object *args, object *env) { #if defined(gfxsupport) (void) env; - uint16_t params[4], colour = COLOR_WHITE; + uint16_t params[4], colour = FOREGROUND_COLOR; for (int i=0; i<4; i++) { params[i] = checkinteger(DRAWLINE, car(args)); args = cdr(args); } if (args != NULL) colour = checkinteger(DRAWLINE, car(args)); tft.drawLine(params[0], params[1], params[2], params[3], colour); @@ -4208,7 +4205,7 @@ object *fn_drawline (object *args, object *env) { object *fn_drawrect (object *args, object *env) { #if defined(gfxsupport) (void) env; - uint16_t params[4], colour = COLOR_WHITE; + uint16_t params[4], colour = FOREGROUND_COLOR; for (int i=0; i<4; i++) { params[i] = checkinteger(DRAWRECT, car(args)); args = cdr(args); } if (args != NULL) colour = checkinteger(DRAWRECT, car(args)); tft.drawRect(params[0], params[1], params[2], params[3], colour); @@ -4219,7 +4216,7 @@ object *fn_drawrect (object *args, object *env) { object *fn_fillrect (object *args, object *env) { #if defined(gfxsupport) (void) env; - uint16_t params[4], colour = COLOR_WHITE; + uint16_t params[4], colour = FOREGROUND_COLOR; for (int i=0; i<4; i++) { params[i] = checkinteger(FILLRECT, car(args)); args = cdr(args); } if (args != NULL) colour = checkinteger(FILLRECT, car(args)); tft.fillRect(params[0], params[1], params[2], params[3], colour); @@ -4230,7 +4227,7 @@ object *fn_fillrect (object *args, object *env) { object *fn_drawcircle (object *args, object *env) { #if defined(gfxsupport) (void) env; - uint16_t params[3], colour = COLOR_WHITE; + uint16_t params[3], colour = FOREGROUND_COLOR; for (int i=0; i<3; i++) { params[i] = checkinteger(DRAWCIRCLE, car(args)); args = cdr(args); } if (args != NULL) colour = checkinteger(DRAWCIRCLE, car(args)); tft.drawCircle(params[0], params[1], params[2], colour); @@ -4241,7 +4238,7 @@ object *fn_drawcircle (object *args, object *env) { object *fn_fillcircle (object *args, object *env) { #if defined(gfxsupport) (void) env; - uint16_t params[3], colour = COLOR_WHITE; + uint16_t params[3], colour = FOREGROUND_COLOR; for (int i=0; i<3; i++) { params[i] = checkinteger(FILLCIRCLE, car(args)); args = cdr(args); } if (args != NULL) colour = checkinteger(FILLCIRCLE, car(args)); tft.fillCircle(params[0], params[1], params[2], colour); @@ -4252,7 +4249,7 @@ object *fn_fillcircle (object *args, object *env) { object *fn_drawroundrect (object *args, object *env) { #if defined(gfxsupport) (void) env; - uint16_t params[5], colour = COLOR_WHITE; + uint16_t params[5], colour = FOREGROUND_COLOR; for (int i=0; i<5; i++) { params[i] = checkinteger(DRAWROUNDRECT, car(args)); args = cdr(args); } if (args != NULL) colour = checkinteger(DRAWROUNDRECT, car(args)); tft.drawRoundRect(params[0], params[1], params[2], params[3], params[4], colour); @@ -4263,7 +4260,7 @@ object *fn_drawroundrect (object *args, object *env) { object *fn_fillroundrect (object *args, object *env) { #if defined(gfxsupport) (void) env; - uint16_t params[5], colour = COLOR_WHITE; + uint16_t params[5], colour = FOREGROUND_COLOR; for (int i=0; i<5; i++) { params[i] = checkinteger(FILLROUNDRECT, car(args)); args = cdr(args); } if (args != NULL) colour = checkinteger(FILLROUNDRECT, car(args)); tft.fillRoundRect(params[0], params[1], params[2], params[3], params[4], colour); @@ -4274,7 +4271,7 @@ object *fn_fillroundrect (object *args, object *env) { object *fn_drawtriangle (object *args, object *env) { #if defined(gfxsupport) (void) env; - uint16_t params[6], colour = COLOR_WHITE; + uint16_t params[6], colour = FOREGROUND_COLOR; for (int i=0; i<6; i++) { params[i] = checkinteger(DRAWTRIANGLE, car(args)); args = cdr(args); } if (args != NULL) colour = checkinteger(DRAWTRIANGLE, car(args)); tft.drawTriangle(params[0], params[1], params[2], params[3], params[4], params[5], colour); @@ -4285,7 +4282,7 @@ object *fn_drawtriangle (object *args, object *env) { object *fn_filltriangle (object *args, object *env) { #if defined(gfxsupport) (void) env; - uint16_t params[6], colour = COLOR_WHITE; + uint16_t params[6], colour = FOREGROUND_COLOR; for (int i=0; i<6; i++) { params[i] = checkinteger(FILLTRIANGLE, car(args)); args = cdr(args); } if (args != NULL) colour = checkinteger(FILLTRIANGLE, car(args)); tft.fillTriangle(params[0], params[1], params[2], params[3], params[4], params[5], colour); @@ -4296,7 +4293,7 @@ object *fn_filltriangle (object *args, object *env) { object *fn_drawchar (object *args, object *env) { #if defined(gfxsupport) (void) env; - uint16_t colour = COLOR_WHITE, bg = COLOR_BLACK, size = 1; + uint16_t colour = FOREGROUND_COLOR, bg = BACKGROUND_COLOR, size = 1; object *more = cdr(cddr(args)); if (more != NULL) { colour = checkinteger(DRAWCHAR, car(more)); @@ -4349,7 +4346,7 @@ object *fn_settextwrap (object *args, object *env) { object *fn_fillscreen (object *args, object *env) { #if defined(gfxsupport) (void) env; - uint16_t colour = COLOR_BLACK; + uint16_t colour = BACKGROUND_COLOR; if (args != NULL) colour = checkinteger(FILLSCREEN, first(args)); tft.fillScreen(colour); #endif @@ -5519,11 +5516,11 @@ object *read (gfun_t gfun) { void initgfx () { #if defined(gfxsupport) - tft.initR(INITR_BLACKTAB); - tft.setRotation(1); - pinMode(TFT_BACKLIGHT, OUTPUT); - digitalWrite(TFT_BACKLIGHT, HIGH); - tft.fillScreen(ST77XX_BLACK); + tft.setRotation(1); + tft.setTextSize(1); + tft.setCursor(0, 8); + tft.fillScreen(BACKGROUND_COLOR); + tft.setTextColor(FOREGROUND_COLOR); #endif }