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

View File

@@ -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 <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#define COLOR_WHITE 0xffff
#define COLOR_BLACK 0
// #include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <Adafruit_ILI9341.h>
#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
}