This commit is contained in:
Kyle Isom 2023-10-01 16:06:40 -07:00
parent 3997683657
commit 25c76c67ce
5 changed files with 85 additions and 30 deletions

11
stage2/include/colors.h Normal file
View File

@ -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

View File

@ -1,5 +1,16 @@
#include <Adafruit_NeoPixel.h> #include <Adafruit_NeoPixel.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <Fonts/FreeSans12pt7b.h>
#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); Adafruit_NeoPixel pixels(1, 11, NEO_GRB + NEO_KHZ800);
auto cOff = pixels.Color(0, 0, 0); auto cOff = pixels.Color(0, 0, 0);
@ -15,6 +26,19 @@ setup()
pixels.begin(); pixels.begin();
pixels.clear(); pixels.clear();
pixels.show(); 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(); pixels.show();
} }
void void
pixelOff() pixelOff()
{ {
@ -64,4 +89,5 @@ loop()
static bool on = false; static bool on = false;
on = blink(on); on = blink(on);
delayMicroseconds(100);
} }

11
ulisp/include/colors.h Normal file
View File

@ -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

View File

@ -16,7 +16,17 @@ build_cache_dir = ~/.platformio/work/cache
[env] [env]
platform = atmelsam platform = atmelsam
framework = arduino 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] [env:adafruit_feather_m4]
board = adafruit_feather_m4 board = adafruit_feather_m4

View File

@ -15,7 +15,7 @@ const char LispLibrary[] PROGMEM = "";
#define printfreespace #define printfreespace
// #define printgcs // #define printgcs
#define sdcardsupport #define sdcardsupport
// #define gfxsupport #define gfxsupport
// #define lisplibrary // #define lisplibrary
#define assemblerlist #define assemblerlist
// #define lineeditor // #define lineeditor
@ -31,18 +31,15 @@ const char LispLibrary[] PROGMEM = "";
#if defined(gfxsupport) #if defined(gfxsupport)
#include <Adafruit_GFX.h> // Core graphics library #include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735 // #include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#define COLOR_WHITE 0xffff #include <Adafruit_ILI9341.h>
#define COLOR_BLACK 0 #include "colors.h"
#define BACKGROUND_COLOR 0xDEFB
#define FOREGROUND_COLOR BLACK
// Adafruit PyBadge/PyGamer #define TFT_CS 9
#define TFT_CS 44 // Chip select #define TFT_DC 10
#define TFT_RST 46 // Display reset Adafruit_ILI9341 tft(TFT_CS, TFT_DC);
#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);
#endif #endif
#if defined(sdcardsupport) #if defined(sdcardsupport)
@ -4187,7 +4184,7 @@ object *fn_listlibrary (object *args, object *env) {
object *fn_drawpixel (object *args, object *env) { object *fn_drawpixel (object *args, object *env) {
#if defined(gfxsupport) #if defined(gfxsupport)
(void) env; (void) env;
uint16_t colour = COLOR_WHITE; uint16_t colour = FOREGROUND_COLOR;
if (cddr(args) != NULL) colour = checkinteger(DRAWPIXEL, third(args)); if (cddr(args) != NULL) colour = checkinteger(DRAWPIXEL, third(args));
tft.drawPixel(checkinteger(DRAWPIXEL, first(args)), checkinteger(DRAWPIXEL, second(args)), colour); tft.drawPixel(checkinteger(DRAWPIXEL, first(args)), checkinteger(DRAWPIXEL, second(args)), colour);
#endif #endif
@ -4197,7 +4194,7 @@ object *fn_drawpixel (object *args, object *env) {
object *fn_drawline (object *args, object *env) { object *fn_drawline (object *args, object *env) {
#if defined(gfxsupport) #if defined(gfxsupport)
(void) env; (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); } for (int i=0; i<4; i++) { params[i] = checkinteger(DRAWLINE, car(args)); args = cdr(args); }
if (args != NULL) colour = checkinteger(DRAWLINE, car(args)); if (args != NULL) colour = checkinteger(DRAWLINE, car(args));
tft.drawLine(params[0], params[1], params[2], params[3], colour); 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) { object *fn_drawrect (object *args, object *env) {
#if defined(gfxsupport) #if defined(gfxsupport)
(void) env; (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); } for (int i=0; i<4; i++) { params[i] = checkinteger(DRAWRECT, car(args)); args = cdr(args); }
if (args != NULL) colour = checkinteger(DRAWRECT, car(args)); if (args != NULL) colour = checkinteger(DRAWRECT, car(args));
tft.drawRect(params[0], params[1], params[2], params[3], colour); 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) { object *fn_fillrect (object *args, object *env) {
#if defined(gfxsupport) #if defined(gfxsupport)
(void) env; (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); } for (int i=0; i<4; i++) { params[i] = checkinteger(FILLRECT, car(args)); args = cdr(args); }
if (args != NULL) colour = checkinteger(FILLRECT, car(args)); if (args != NULL) colour = checkinteger(FILLRECT, car(args));
tft.fillRect(params[0], params[1], params[2], params[3], colour); 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) { object *fn_drawcircle (object *args, object *env) {
#if defined(gfxsupport) #if defined(gfxsupport)
(void) env; (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); } for (int i=0; i<3; i++) { params[i] = checkinteger(DRAWCIRCLE, car(args)); args = cdr(args); }
if (args != NULL) colour = checkinteger(DRAWCIRCLE, car(args)); if (args != NULL) colour = checkinteger(DRAWCIRCLE, car(args));
tft.drawCircle(params[0], params[1], params[2], colour); 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) { object *fn_fillcircle (object *args, object *env) {
#if defined(gfxsupport) #if defined(gfxsupport)
(void) env; (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); } for (int i=0; i<3; i++) { params[i] = checkinteger(FILLCIRCLE, car(args)); args = cdr(args); }
if (args != NULL) colour = checkinteger(FILLCIRCLE, car(args)); if (args != NULL) colour = checkinteger(FILLCIRCLE, car(args));
tft.fillCircle(params[0], params[1], params[2], colour); 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) { object *fn_drawroundrect (object *args, object *env) {
#if defined(gfxsupport) #if defined(gfxsupport)
(void) env; (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); } for (int i=0; i<5; i++) { params[i] = checkinteger(DRAWROUNDRECT, car(args)); args = cdr(args); }
if (args != NULL) colour = checkinteger(DRAWROUNDRECT, car(args)); if (args != NULL) colour = checkinteger(DRAWROUNDRECT, car(args));
tft.drawRoundRect(params[0], params[1], params[2], params[3], params[4], colour); 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) { object *fn_fillroundrect (object *args, object *env) {
#if defined(gfxsupport) #if defined(gfxsupport)
(void) env; (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); } for (int i=0; i<5; i++) { params[i] = checkinteger(FILLROUNDRECT, car(args)); args = cdr(args); }
if (args != NULL) colour = checkinteger(FILLROUNDRECT, car(args)); if (args != NULL) colour = checkinteger(FILLROUNDRECT, car(args));
tft.fillRoundRect(params[0], params[1], params[2], params[3], params[4], colour); 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) { object *fn_drawtriangle (object *args, object *env) {
#if defined(gfxsupport) #if defined(gfxsupport)
(void) env; (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); } for (int i=0; i<6; i++) { params[i] = checkinteger(DRAWTRIANGLE, car(args)); args = cdr(args); }
if (args != NULL) colour = checkinteger(DRAWTRIANGLE, car(args)); if (args != NULL) colour = checkinteger(DRAWTRIANGLE, car(args));
tft.drawTriangle(params[0], params[1], params[2], params[3], params[4], params[5], colour); 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) { object *fn_filltriangle (object *args, object *env) {
#if defined(gfxsupport) #if defined(gfxsupport)
(void) env; (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); } for (int i=0; i<6; i++) { params[i] = checkinteger(FILLTRIANGLE, car(args)); args = cdr(args); }
if (args != NULL) colour = checkinteger(FILLTRIANGLE, car(args)); if (args != NULL) colour = checkinteger(FILLTRIANGLE, car(args));
tft.fillTriangle(params[0], params[1], params[2], params[3], params[4], params[5], colour); 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) { object *fn_drawchar (object *args, object *env) {
#if defined(gfxsupport) #if defined(gfxsupport)
(void) env; (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)); object *more = cdr(cddr(args));
if (more != NULL) { if (more != NULL) {
colour = checkinteger(DRAWCHAR, car(more)); colour = checkinteger(DRAWCHAR, car(more));
@ -4349,7 +4346,7 @@ object *fn_settextwrap (object *args, object *env) {
object *fn_fillscreen (object *args, object *env) { object *fn_fillscreen (object *args, object *env) {
#if defined(gfxsupport) #if defined(gfxsupport)
(void) env; (void) env;
uint16_t colour = COLOR_BLACK; uint16_t colour = BACKGROUND_COLOR;
if (args != NULL) colour = checkinteger(FILLSCREEN, first(args)); if (args != NULL) colour = checkinteger(FILLSCREEN, first(args));
tft.fillScreen(colour); tft.fillScreen(colour);
#endif #endif
@ -5519,11 +5516,11 @@ object *read (gfun_t gfun) {
void initgfx () { void initgfx () {
#if defined(gfxsupport) #if defined(gfxsupport)
tft.initR(INITR_BLACKTAB); tft.setRotation(1);
tft.setRotation(1); tft.setTextSize(1);
pinMode(TFT_BACKLIGHT, OUTPUT); tft.setCursor(0, 8);
digitalWrite(TFT_BACKLIGHT, HIGH); tft.fillScreen(BACKGROUND_COLOR);
tft.fillScreen(ST77XX_BLACK); tft.setTextColor(FOREGROUND_COLOR);
#endif #endif
} }