Baseline: Migrated from local arduino IDE project, compiles but contains dead code and needs refactoring
This commit is contained in:
134
src/Bitmaps.cpp
Normal file
134
src/Bitmaps.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
#include "Bitmaps.h"
|
||||
#include <SPI.h>
|
||||
|
||||
const unsigned char spash_screen_BMP[] = {
|
||||
// 'SplashScreen, 128x128px Memory usage: 2kb so... easy tiger! Dont get carried away
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0xf0, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x03, 0x18, 0x00, 0x1f, 0x00, 0x00, 0xe0, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x06, 0x0c, 0x00, 0x31, 0x80, 0x03, 0xf0, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x04, 0x06, 0x00, 0x40, 0xc0, 0x07, 0x30, 0x01, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x18, 0x03, 0x01, 0xc0, 0x40, 0x0c, 0x18, 0x01, 0x8c, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x18, 0x03, 0x03, 0x80, 0x60, 0x78, 0x08, 0x06, 0x06, 0x00, 0x7c, 0x00, 0x10, 0x00, 0x00,
|
||||
0x00, 0x30, 0x01, 0x8e, 0x00, 0x30, 0xe0, 0x0c, 0x0c, 0x06, 0x00, 0xe6, 0x00, 0x78, 0x00, 0x00,
|
||||
0x00, 0x60, 0x00, 0xf8, 0x00, 0x37, 0x80, 0x06, 0x38, 0x03, 0x0f, 0x86, 0x00, 0xc8, 0x00, 0x00,
|
||||
0x00, 0x40, 0x00, 0x70, 0x00, 0x0f, 0x00, 0x02, 0x60, 0x03, 0x1e, 0x03, 0x03, 0x8c, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0xc0, 0x01, 0xf0, 0x03, 0x0e, 0x06, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0xe0, 0x01, 0x9c, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb0, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x01, 0x80, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x7f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0xe0, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x18, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0xef, 0xff, 0xf0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x30, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x7c, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x60, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x60, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x60, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x60, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x60, 0x00, 0x01, 0x80, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x60, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x60, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x20, 0x00, 0x06, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x30, 0x00, 0x04, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x1c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x07, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x3f, 0xe0, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0f, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0xc0, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc0, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
4
src/Bitmaps.h
Normal file
4
src/Bitmaps.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
extern const unsigned char spash_screen_BMP[];
|
||||
|
||||
92
src/Menu.cpp
Normal file
92
src/Menu.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#include "Menu.h"
|
||||
#include "Programs/Snake/Snake.h"
|
||||
#include "Programs/Settings/Settings.h"
|
||||
#include "Programs/Asteroids/Asteroids.h"
|
||||
#include "Programs/Calculator/Calculator.h"
|
||||
|
||||
// ... include headers for your other programs here
|
||||
void requestProgramChange(Program* program);
|
||||
|
||||
namespace Menu {
|
||||
|
||||
// --- 1. Define the MenuItem struct ---
|
||||
struct MenuItem {
|
||||
const char* text;
|
||||
Program* program;
|
||||
};
|
||||
|
||||
// --- 2. Create the menuItems array ---
|
||||
MenuItem menuItems[] = {
|
||||
{"Snake", new Snake::Snake()},
|
||||
{"Settings", new Settings::Settings()},
|
||||
{"Asteroids", new Asteroids::Asteroids()},
|
||||
{"Calculator", new Calculator::Calculator()}
|
||||
};
|
||||
|
||||
const int TOTAL_MENU_ITEMS = sizeof(menuItems) / sizeof(menuItems[0]);
|
||||
const int MAX_VISIBLE_ITEMS = 6;
|
||||
const int FONT_HEIGHT = 8;
|
||||
|
||||
// --- 3. Implement the Menu class methods ---
|
||||
|
||||
int selectedIndex = 0;
|
||||
int viewOffset = 0;
|
||||
|
||||
void Menu::setup() {
|
||||
// Not needed for the menu
|
||||
}
|
||||
|
||||
void Menu::onEnter(Adafruit_SSD1351 *tft) {
|
||||
// Reset the menu state when we enter it
|
||||
selectedIndex = 0;
|
||||
viewOffset = 0;
|
||||
Menu::disableInfoBar = false;
|
||||
tft->fillRect(0, 0, 128, 128, BLACK);
|
||||
}
|
||||
|
||||
void Menu::onExit() {
|
||||
// Not needed for the menu
|
||||
}
|
||||
|
||||
void Menu::loop(Adafruit_SSD1351 *tft, inputData *userInputs) {
|
||||
// --- Input Handling ---
|
||||
static int previousJoystickCommand = COMMAND_NO;
|
||||
int currentJoystickCommand = userInputs->joystickCommand;
|
||||
|
||||
if ((currentJoystickCommand & COMMAND_DOWN) && !(previousJoystickCommand & COMMAND_DOWN)) {
|
||||
selectedIndex++;
|
||||
if (selectedIndex >= TOTAL_MENU_ITEMS) {
|
||||
selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
if ((currentJoystickCommand & COMMAND_UP) && !(previousJoystickCommand & COMMAND_UP)) {
|
||||
selectedIndex--;
|
||||
if (selectedIndex < 0) {
|
||||
selectedIndex = TOTAL_MENU_ITEMS - 1;
|
||||
}
|
||||
}
|
||||
|
||||
previousJoystickCommand = currentJoystickCommand;
|
||||
|
||||
// --- Drawing ---
|
||||
for (int i = 0; i < MAX_VISIBLE_ITEMS; i++) {
|
||||
int itemIndex = i + viewOffset;
|
||||
if (itemIndex < TOTAL_MENU_ITEMS) {
|
||||
int yPos = 20 + i * (FONT_HEIGHT + 2);
|
||||
tft->setCursor(10, yPos);
|
||||
if (itemIndex == selectedIndex) {
|
||||
tft->setTextColor(BLACK, WHITE);
|
||||
} else {
|
||||
tft->setTextColor(WHITE, BLACK);
|
||||
}
|
||||
tft->println(menuItems[itemIndex].text);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Program Switching ---
|
||||
if (userInputs->buttonTop.isReleased()) {
|
||||
requestProgramChange(menuItems[selectedIndex].program);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
16
src/Menu.h
Normal file
16
src/Menu.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <Adafruit_SSD1351.h>
|
||||
|
||||
#include "utility.h"
|
||||
|
||||
namespace Menu{
|
||||
|
||||
class Menu : public Program {
|
||||
public:
|
||||
void setup() override;
|
||||
void loop(Adafruit_SSD1351 *tft, inputData *userInputs) override;
|
||||
void onEnter(Adafruit_SSD1351 *tft) override;
|
||||
void onExit()override;
|
||||
};
|
||||
}
|
||||
22
src/Programs/Asteroids/Asteroids.cpp
Normal file
22
src/Programs/Asteroids/Asteroids.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
#include "Asteroids.h"
|
||||
|
||||
namespace Asteroids{
|
||||
void Asteroids::setup(){
|
||||
// start method
|
||||
Serial.println("Starting Asteroids");
|
||||
return;
|
||||
}
|
||||
void Asteroids::loop(Adafruit_SSD1351 *tft, inputData *userInput){
|
||||
// update method
|
||||
Serial.println("Running Asteroids");
|
||||
return;
|
||||
}
|
||||
void Asteroids::onEnter(Adafruit_SSD1351 *tft){
|
||||
|
||||
}
|
||||
|
||||
void Asteroids::onExit(){
|
||||
|
||||
}
|
||||
};
|
||||
16
src/Programs/Asteroids/Asteroids.h
Normal file
16
src/Programs/Asteroids/Asteroids.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <Adafruit_SSD1351.h>
|
||||
|
||||
#include "../../utility.h"
|
||||
|
||||
|
||||
namespace Asteroids{
|
||||
class Asteroids : public Program {
|
||||
public:
|
||||
void setup() override;
|
||||
void loop(Adafruit_SSD1351 *tft, inputData *userInput) override;
|
||||
void onEnter(Adafruit_SSD1351 *tft) override;
|
||||
void onExit()override;
|
||||
};
|
||||
}
|
||||
119
src/Programs/Calculator/Calculator.cpp
Normal file
119
src/Programs/Calculator/Calculator.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
#include <Arduino.h>
|
||||
#include "Calculator.h"
|
||||
|
||||
namespace Calculator{
|
||||
void Calculator::setup(){
|
||||
// Code for setup
|
||||
}
|
||||
void Calculator::loop(Adafruit_SSD1351 *tft, inputData *userInput){
|
||||
|
||||
static int previousJoystickCommand = COMMAND_NO;
|
||||
int currentJoystickCommand = userInput->joystickCommand;
|
||||
|
||||
if ((currentJoystickCommand & COMMAND_UP) && !(previousJoystickCommand & COMMAND_UP)) {
|
||||
cursorY--;
|
||||
if (cursorY < 0) cursorY = 3;
|
||||
}
|
||||
if ((currentJoystickCommand & COMMAND_DOWN) && !(previousJoystickCommand & COMMAND_DOWN)) {
|
||||
cursorY++;
|
||||
if (cursorY > 3) cursorY = 0;
|
||||
}
|
||||
if ((currentJoystickCommand & COMMAND_LEFT) && !(previousJoystickCommand & COMMAND_LEFT)) {
|
||||
cursorX--;
|
||||
if (cursorX < 0) cursorX = 3;
|
||||
}
|
||||
if ((currentJoystickCommand & COMMAND_RIGHT) && !(previousJoystickCommand & COMMAND_RIGHT)) {
|
||||
cursorX++;
|
||||
if (cursorX > 3) cursorX = 0;
|
||||
}
|
||||
|
||||
if (userInput->joyStickButton.isReleased()) {
|
||||
const char* selectedButton = buttonGrid[cursorY][cursorX];
|
||||
handleButtonPress(selectedButton);
|
||||
}
|
||||
|
||||
previousJoystickCommand = currentJoystickCommand;
|
||||
|
||||
drawCalculator(tft);
|
||||
}
|
||||
|
||||
void Calculator::handleButtonPress(const char* button) {
|
||||
char buttonChar = button[0];
|
||||
|
||||
if (buttonChar >= '0' && buttonChar <= '9') {
|
||||
if (strcmp(display, "0") == 0 || newNumber) {
|
||||
strcpy(display, button);
|
||||
newNumber = false;
|
||||
} else if (strlen(display) < 15) {
|
||||
strcat(display, button);
|
||||
}
|
||||
} else if (buttonChar == 'C') {
|
||||
strcpy(display, "0");
|
||||
storedValue = 0;
|
||||
operation = ' ';
|
||||
newNumber = true;
|
||||
} else if (buttonChar == '+' || buttonChar == '-' || buttonChar == '*' || buttonChar == '/') {
|
||||
storedValue = atof(display);
|
||||
operation = buttonChar;
|
||||
newNumber = true;
|
||||
} else if (buttonChar == '=') {
|
||||
if (operation != ' ') {
|
||||
double secondValue = atof(display);
|
||||
double result = 0;
|
||||
switch (operation) {
|
||||
case '+': result = storedValue + secondValue; break;
|
||||
case '-': result = storedValue - secondValue; break;
|
||||
case '*': result = storedValue * secondValue; break;
|
||||
case '/': result = storedValue / secondValue; break;
|
||||
}
|
||||
dtostrf(result, 0, 2, display);
|
||||
operation = ' ';
|
||||
newNumber = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Calculator::onEnter(Adafruit_SSD1351 *tft){
|
||||
// Code to run when program is entered
|
||||
Calculator::disableInfoBar = true;
|
||||
// clear the screen
|
||||
tft->fillRect(0, 0, 128, 128, BLACK);
|
||||
}
|
||||
|
||||
void Calculator::onExit(){
|
||||
// Code to run when program is exited
|
||||
}
|
||||
void Calculator::drawCalculator(Adafruit_SSD1351 *tft) {
|
||||
// Clear only the top display area to reduce flicker
|
||||
tft->fillRect(0, 0, 128, 30, BLACK);
|
||||
tft->setTextSize(2);
|
||||
tft->setCursor(10, 10);
|
||||
tft->println(display);
|
||||
|
||||
int buttonWidth = 32;
|
||||
int buttonHeight = 24;
|
||||
int startX = 0;
|
||||
int startY = 30;
|
||||
|
||||
for (int y = 0; y < 4; y++) {
|
||||
for (int x = 0; x < 4; x++) {
|
||||
int buttonX = startX + x * buttonWidth;
|
||||
int buttonY = startY + y * buttonHeight;
|
||||
|
||||
if (x == cursorX && y == cursorY) {
|
||||
// draw selected Item
|
||||
tft->fillRect(buttonX, buttonY, buttonWidth, buttonHeight, WHITE);
|
||||
tft->setTextColor(BLACK);
|
||||
} else {
|
||||
// Fill the button background black to "un-highlight" it
|
||||
tft->fillRect(buttonX, buttonY, buttonWidth, buttonHeight, BLACK);
|
||||
//tft->drawRect(buttonX, buttonY, buttonWidth, buttonHeight, WHITE);
|
||||
tft->setTextColor(WHITE);
|
||||
}
|
||||
|
||||
tft->setCursor(buttonX + 10, buttonY + 5);
|
||||
tft->print(buttonGrid[y][x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
37
src/Programs/Calculator/Calculator.h
Normal file
37
src/Programs/Calculator/Calculator.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <Adafruit_SSD1351.h>
|
||||
|
||||
#include "../../utility.h"
|
||||
|
||||
|
||||
namespace Calculator{
|
||||
|
||||
class Calculator : public Program {
|
||||
public:
|
||||
void setup() override;
|
||||
void loop(Adafruit_SSD1351 *tft, inputData *userInput) override;
|
||||
void onEnter(Adafruit_SSD1351 *tft) override;
|
||||
void onExit()override;
|
||||
|
||||
private:
|
||||
void drawCalculator(Adafruit_SSD1351 *tft);
|
||||
void handleButtonPress(const char* button);
|
||||
|
||||
int cursorX = 0;
|
||||
int cursorY = 0;
|
||||
|
||||
char display[16] = "0";
|
||||
double storedValue = 0;
|
||||
char operation = ' ';
|
||||
bool newNumber = true;
|
||||
|
||||
const char* buttonGrid[4][4] = {
|
||||
{"1", "2", "3", "+"},
|
||||
{"4", "5", "6", "-"},
|
||||
{"7", "8", "9", "*"},
|
||||
{"C", "0", "=", "/"}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
41
src/Programs/Keyboard.cpp
Normal file
41
src/Programs/Keyboard.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#include "Keyboard.h"
|
||||
|
||||
namespace Keyboard{
|
||||
void Keyboard::render(Adafruit_SSD1351 *tft){
|
||||
// Clear the keyboard area (e.g., bottom half of screen)
|
||||
tft->fillRect(0, 64, 128, 64, BLACK);
|
||||
|
||||
// Draw the typed text at the top of the keyboard area
|
||||
tft->setTextSize(1);
|
||||
tft->setCursor(5, 70);
|
||||
tft->setTextColor(WHITE);
|
||||
tft->println(typedText);
|
||||
|
||||
// Draw the keyboard grid
|
||||
int buttonWidth = 21;
|
||||
int buttonHeight = 10; // Adjusted for 5 rows in the remaining space
|
||||
int startX = 0;
|
||||
int startY = 85;
|
||||
|
||||
for (int y = 0; y < 5; y++) {
|
||||
for (int x = 0; x < 6; x++) {
|
||||
int buttonX = startX + x * buttonWidth;
|
||||
int buttonY = startY + y * buttonHeight;
|
||||
|
||||
if (x == cursorX && y == cursorY) {
|
||||
tft->fillRect(buttonX, buttonY, buttonWidth, buttonHeight, WHITE);
|
||||
tft->setTextColor(BLACK);
|
||||
} else {
|
||||
tft->fillRect(buttonX, buttonY, buttonWidth, buttonHeight, BLACK);
|
||||
tft->drawRect(buttonX, buttonY, buttonWidth, buttonHeight, WHITE);
|
||||
tft->setTextColor(WHITE);
|
||||
}
|
||||
|
||||
// Simple centering for text
|
||||
tft->setCursor(buttonX + (buttonWidth/2) - 3, buttonY + (buttonHeight/2) - 4);
|
||||
tft->print(keyboardLayout[y][x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
28
src/Programs/Keyboard.h
Normal file
28
src/Programs/Keyboard.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <Adafruit_SSD1351.h>
|
||||
|
||||
#include "../utility.h"
|
||||
|
||||
|
||||
namespace Keyboard{
|
||||
|
||||
class Keyboard {
|
||||
public:
|
||||
void render(Adafruit_SSD1351 *tft);
|
||||
|
||||
private:
|
||||
int cursorX = 0;
|
||||
int cursorY = 0;
|
||||
|
||||
char typedText[32] = "";
|
||||
|
||||
const char* keyboardLayout[5][6] = {
|
||||
{"A", "B", "C", "D", "E", "F"},
|
||||
{"G", "H", "I", "J", "K", "L"},
|
||||
{"M", "N", "O", "P", "Q", "R"},
|
||||
{"S", "T", "U", "V", "W", "X"},
|
||||
{"Y", "Z", ".", "<", "_", "ENT"}
|
||||
};
|
||||
};
|
||||
}
|
||||
21
src/Programs/Messaging/Messaging.cpp
Normal file
21
src/Programs/Messaging/Messaging.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "Messaging.h"
|
||||
|
||||
namespace Messaging{
|
||||
void Messaging::setup(){
|
||||
// start method
|
||||
Serial.println("Starting Messaging");
|
||||
return;
|
||||
}
|
||||
void Messaging::loop(Adafruit_SSD1351 *tft, inputData *userInput){
|
||||
// update method
|
||||
Serial.println("Running Messaging");
|
||||
return;
|
||||
}
|
||||
void Messaging::onEnter(Adafruit_SSD1351 *tft){
|
||||
|
||||
}
|
||||
|
||||
void Messaging::onExit(){
|
||||
|
||||
}
|
||||
};
|
||||
17
src/Programs/Messaging/Messaging.h
Normal file
17
src/Programs/Messaging/Messaging.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <Adafruit_SSD1351.h>
|
||||
|
||||
#include "../../utility.h"
|
||||
|
||||
|
||||
namespace Messaging{
|
||||
class Messaging : public Program {
|
||||
public:
|
||||
void setup() override;
|
||||
void loop(Adafruit_SSD1351 *tft, inputData *userInput) override;
|
||||
void onEnter(Adafruit_SSD1351 *tft) override;
|
||||
void onExit()override;
|
||||
};
|
||||
}
|
||||
21
src/Programs/Settings/Settings.cpp
Normal file
21
src/Programs/Settings/Settings.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "Settings.h"
|
||||
|
||||
namespace Settings{
|
||||
void Settings::setup(){
|
||||
// start method
|
||||
Serial.println("Starting Settings");
|
||||
return;
|
||||
}
|
||||
void Settings::loop(Adafruit_SSD1351 *tft, inputData *userInput){
|
||||
// update method
|
||||
Serial.println("Running Settings");
|
||||
return;
|
||||
}
|
||||
void Settings::onEnter(Adafruit_SSD1351 *tft){
|
||||
|
||||
}
|
||||
|
||||
void Settings::onExit(){
|
||||
|
||||
}
|
||||
};
|
||||
18
src/Programs/Settings/Settings.h
Normal file
18
src/Programs/Settings/Settings.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <Adafruit_SSD1351.h>
|
||||
|
||||
#include "../../utility.h"
|
||||
|
||||
|
||||
namespace Settings{
|
||||
class Settings : public Program {
|
||||
public:
|
||||
void setup() override;
|
||||
void loop(Adafruit_SSD1351 *tft, inputData *userInput) override;
|
||||
void onEnter(Adafruit_SSD1351 *tft) override;
|
||||
void onExit()override;
|
||||
};
|
||||
}
|
||||
|
||||
22
src/Programs/Snake/Snake.cpp
Normal file
22
src/Programs/Snake/Snake.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "Snake.h"
|
||||
|
||||
namespace Snake{
|
||||
void Snake::setup(){
|
||||
// start method
|
||||
Serial.println("Starting Snake");
|
||||
return;
|
||||
}
|
||||
void Snake::loop(Adafruit_SSD1351 *tft, inputData *userInput){
|
||||
// update method
|
||||
Serial.println("Running Snake");
|
||||
return;
|
||||
}
|
||||
void Snake::onEnter(Adafruit_SSD1351 *tft){
|
||||
// Show Snake game logo for a second or two
|
||||
// could make the 7 seg do like a little snake impression by having the led's move around
|
||||
}
|
||||
|
||||
void Snake::onExit(){
|
||||
|
||||
}
|
||||
};
|
||||
18
src/Programs/Snake/Snake.h
Normal file
18
src/Programs/Snake/Snake.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <Adafruit_SSD1351.h>
|
||||
|
||||
#include "../../utility.h"
|
||||
|
||||
|
||||
namespace Snake{
|
||||
|
||||
class Snake : public Program {
|
||||
public:
|
||||
void setup() override;
|
||||
void loop(Adafruit_SSD1351 *tft, inputData *userInput) override;
|
||||
void onEnter(Adafruit_SSD1351 *tft) override;
|
||||
void onExit()override;
|
||||
};
|
||||
}
|
||||
401
src/Resources/Adafruit_GFX.h
Normal file
401
src/Resources/Adafruit_GFX.h
Normal file
@@ -0,0 +1,401 @@
|
||||
#ifndef _ADAFRUIT_GFX_H
|
||||
#define _ADAFRUIT_GFX_H
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#include "Print.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
#include "gfxfont.h"
|
||||
|
||||
#include <Adafruit_I2CDevice.h>
|
||||
#include <Adafruit_SPIDevice.h>
|
||||
|
||||
/// A generic graphics superclass that can handle all sorts of drawing. At a
|
||||
/// minimum you can subclass and provide drawPixel(). At a maximum you can do a
|
||||
/// ton of overriding to optimize. Used for any/all Adafruit displays!
|
||||
class Adafruit_GFX : public Print {
|
||||
|
||||
public:
|
||||
Adafruit_GFX(int16_t w, int16_t h); // Constructor
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Draw to the screen/framebuffer/etc.
|
||||
Must be overridden in subclass.
|
||||
@param x X coordinate in pixels
|
||||
@param y Y coordinate in pixels
|
||||
@param color 16-bit pixel color.
|
||||
*/
|
||||
/**********************************************************************/
|
||||
virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
|
||||
|
||||
// TRANSACTION API / CORE DRAW API
|
||||
// These MAY be overridden by the subclass to provide device-specific
|
||||
// optimized code. Otherwise 'generic' versions are used.
|
||||
virtual void startWrite(void);
|
||||
virtual void writePixel(int16_t x, int16_t y, uint16_t color);
|
||||
virtual void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||
uint16_t color);
|
||||
virtual void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
virtual void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
virtual void writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
|
||||
uint16_t color);
|
||||
virtual void endWrite(void);
|
||||
|
||||
// CONTROL API
|
||||
// These MAY be overridden by the subclass to provide device-specific
|
||||
// optimized code. Otherwise 'generic' versions are used.
|
||||
virtual void setRotation(uint8_t r);
|
||||
virtual void invertDisplay(bool i);
|
||||
|
||||
// BASIC DRAW API
|
||||
// These MAY be overridden by the subclass to provide device-specific
|
||||
// optimized code. Otherwise 'generic' versions are used.
|
||||
|
||||
// It's good to implement those, even if using transaction API
|
||||
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||
uint16_t color);
|
||||
virtual void fillScreen(uint16_t color);
|
||||
// Optional and probably not necessary to change
|
||||
virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
|
||||
uint16_t color);
|
||||
virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||
uint16_t color);
|
||||
|
||||
// These exist only with Adafruit_GFX (no subclass overrides)
|
||||
void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
|
||||
void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
|
||||
uint16_t color);
|
||||
void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
|
||||
void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
|
||||
int16_t delta, uint16_t color);
|
||||
void drawEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh,
|
||||
uint16_t color);
|
||||
void fillEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh,
|
||||
uint16_t color);
|
||||
void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2,
|
||||
int16_t y2, uint16_t color);
|
||||
void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2,
|
||||
int16_t y2, uint16_t color);
|
||||
void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
|
||||
int16_t radius, uint16_t color);
|
||||
void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
|
||||
int16_t radius, uint16_t color);
|
||||
void drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w,
|
||||
int16_t h, uint16_t color);
|
||||
void drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w,
|
||||
int16_t h, uint16_t color, uint16_t bg);
|
||||
void drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h,
|
||||
uint16_t color);
|
||||
void drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h,
|
||||
uint16_t color, uint16_t bg);
|
||||
void drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[], int16_t w,
|
||||
int16_t h, uint16_t color);
|
||||
void drawGrayscaleBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
|
||||
int16_t w, int16_t h);
|
||||
void drawGrayscaleBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w,
|
||||
int16_t h);
|
||||
void drawGrayscaleBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
|
||||
const uint8_t mask[], int16_t w, int16_t h);
|
||||
void drawGrayscaleBitmap(int16_t x, int16_t y, uint8_t *bitmap, uint8_t *mask,
|
||||
int16_t w, int16_t h);
|
||||
void drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[], int16_t w,
|
||||
int16_t h);
|
||||
void drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap, int16_t w,
|
||||
int16_t h);
|
||||
void drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[],
|
||||
const uint8_t mask[], int16_t w, int16_t h);
|
||||
void drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap, uint8_t *mask,
|
||||
int16_t w, int16_t h);
|
||||
void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
|
||||
uint16_t bg, uint8_t size);
|
||||
void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
|
||||
uint16_t bg, uint8_t size_x, uint8_t size_y);
|
||||
void getTextBounds(const char *string, int16_t x, int16_t y, int16_t *x1,
|
||||
int16_t *y1, uint16_t *w, uint16_t *h);
|
||||
void getTextBounds(const __FlashStringHelper *s, int16_t x, int16_t y,
|
||||
int16_t *x1, int16_t *y1, uint16_t *w, uint16_t *h);
|
||||
void getTextBounds(const String &str, int16_t x, int16_t y, int16_t *x1,
|
||||
int16_t *y1, uint16_t *w, uint16_t *h);
|
||||
void setTextSize(uint8_t s);
|
||||
void setTextSize(uint8_t sx, uint8_t sy);
|
||||
void setFont(const GFXfont *f = NULL);
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Set text cursor location
|
||||
@param x X coordinate in pixels
|
||||
@param y Y coordinate in pixels
|
||||
*/
|
||||
/**********************************************************************/
|
||||
void setCursor(int16_t x, int16_t y) {
|
||||
cursor_x = x;
|
||||
cursor_y = y;
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Set text font color with transparant background
|
||||
@param c 16-bit 5-6-5 Color to draw text with
|
||||
@note For 'transparent' background, background and foreground
|
||||
are set to same color rather than using a separate flag.
|
||||
*/
|
||||
/**********************************************************************/
|
||||
void setTextColor(uint16_t c) { textcolor = textbgcolor = c; }
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Set text font color with custom background color
|
||||
@param c 16-bit 5-6-5 Color to draw text with
|
||||
@param bg 16-bit 5-6-5 Color to draw background/fill with
|
||||
*/
|
||||
/**********************************************************************/
|
||||
void setTextColor(uint16_t c, uint16_t bg) {
|
||||
textcolor = c;
|
||||
textbgcolor = bg;
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Set whether text that is too long for the screen width should
|
||||
automatically wrap around to the next line (else clip right).
|
||||
@param w true for wrapping, false for clipping
|
||||
*/
|
||||
/**********************************************************************/
|
||||
void setTextWrap(bool w) { wrap = w; }
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Enable (or disable) Code Page 437-compatible charset.
|
||||
There was an error in glcdfont.c for the longest time -- one
|
||||
character (#176, the 'light shade' block) was missing -- this
|
||||
threw off the index of every character that followed it.
|
||||
But a TON of code has been written with the erroneous
|
||||
character indices. By default, the library uses the original
|
||||
'wrong' behavior and old sketches will still work. Pass
|
||||
'true' to this function to use correct CP437 character values
|
||||
in your code.
|
||||
@param x true = enable (new behavior), false = disable (old behavior)
|
||||
*/
|
||||
/**********************************************************************/
|
||||
void cp437(bool x = true) { _cp437 = x; }
|
||||
|
||||
using Print::write;
|
||||
#if ARDUINO >= 100
|
||||
virtual size_t write(uint8_t);
|
||||
#else
|
||||
virtual void write(uint8_t);
|
||||
#endif
|
||||
|
||||
/************************************************************************/
|
||||
/*!
|
||||
@brief Get width of the display, accounting for current rotation
|
||||
@returns Width in pixels
|
||||
*/
|
||||
/************************************************************************/
|
||||
int16_t width(void) const { return _width; };
|
||||
|
||||
/************************************************************************/
|
||||
/*!
|
||||
@brief Get height of the display, accounting for current rotation
|
||||
@returns Height in pixels
|
||||
*/
|
||||
/************************************************************************/
|
||||
int16_t height(void) const { return _height; }
|
||||
|
||||
/************************************************************************/
|
||||
/*!
|
||||
@brief Get rotation setting for display
|
||||
@returns 0 thru 3 corresponding to 4 cardinal rotations
|
||||
*/
|
||||
/************************************************************************/
|
||||
uint8_t getRotation(void) const { return rotation; }
|
||||
|
||||
// get current cursor position (get rotation safe maximum values,
|
||||
// using: width() for x, height() for y)
|
||||
/************************************************************************/
|
||||
/*!
|
||||
@brief Get text cursor X location
|
||||
@returns X coordinate in pixels
|
||||
*/
|
||||
/************************************************************************/
|
||||
int16_t getCursorX(void) const { return cursor_x; }
|
||||
|
||||
/************************************************************************/
|
||||
/*!
|
||||
@brief Get text cursor Y location
|
||||
@returns Y coordinate in pixels
|
||||
*/
|
||||
/************************************************************************/
|
||||
int16_t getCursorY(void) const { return cursor_y; };
|
||||
|
||||
protected:
|
||||
void charBounds(unsigned char c, int16_t *x, int16_t *y, int16_t *minx,
|
||||
int16_t *miny, int16_t *maxx, int16_t *maxy);
|
||||
int16_t WIDTH; ///< This is the 'raw' display width - never changes
|
||||
int16_t HEIGHT; ///< This is the 'raw' display height - never changes
|
||||
int16_t _width; ///< Display width as modified by current rotation
|
||||
int16_t _height; ///< Display height as modified by current rotation
|
||||
int16_t cursor_x; ///< x location to start print()ing text
|
||||
int16_t cursor_y; ///< y location to start print()ing text
|
||||
uint16_t textcolor; ///< 16-bit background color for print()
|
||||
uint16_t textbgcolor; ///< 16-bit text color for print()
|
||||
uint8_t textsize_x; ///< Desired magnification in X-axis of text to print()
|
||||
uint8_t textsize_y; ///< Desired magnification in Y-axis of text to print()
|
||||
uint8_t rotation; ///< Display rotation (0 thru 3)
|
||||
bool wrap; ///< If set, 'wrap' text at right edge of display
|
||||
bool _cp437; ///< If set, use correct CP437 charset (default is off)
|
||||
GFXfont *gfxFont; ///< Pointer to special font
|
||||
};
|
||||
|
||||
/// A simple drawn button UI element
|
||||
class Adafruit_GFX_Button {
|
||||
|
||||
public:
|
||||
Adafruit_GFX_Button(void);
|
||||
// "Classic" initButton() uses center & size
|
||||
void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y, uint16_t w,
|
||||
uint16_t h, uint16_t outline, uint16_t fill,
|
||||
uint16_t textcolor, char *label, uint8_t textsize);
|
||||
void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y, uint16_t w,
|
||||
uint16_t h, uint16_t outline, uint16_t fill,
|
||||
uint16_t textcolor, char *label, uint8_t textsize_x,
|
||||
uint8_t textsize_y);
|
||||
// New/alt initButton() uses upper-left corner & size
|
||||
void initButtonUL(Adafruit_GFX *gfx, int16_t x1, int16_t y1, uint16_t w,
|
||||
uint16_t h, uint16_t outline, uint16_t fill,
|
||||
uint16_t textcolor, char *label, uint8_t textsize);
|
||||
void initButtonUL(Adafruit_GFX *gfx, int16_t x1, int16_t y1, uint16_t w,
|
||||
uint16_t h, uint16_t outline, uint16_t fill,
|
||||
uint16_t textcolor, char *label, uint8_t textsize_x,
|
||||
uint8_t textsize_y);
|
||||
void drawButton(bool inverted = false);
|
||||
bool contains(int16_t x, int16_t y);
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Sets button state, should be done by some touch function
|
||||
@param p True for pressed, false for not.
|
||||
*/
|
||||
/**********************************************************************/
|
||||
void press(bool p) {
|
||||
laststate = currstate;
|
||||
currstate = p;
|
||||
}
|
||||
|
||||
bool justPressed();
|
||||
bool justReleased();
|
||||
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Query whether the button is currently pressed
|
||||
@returns True if pressed
|
||||
*/
|
||||
/**********************************************************************/
|
||||
bool isPressed(void) { return currstate; };
|
||||
|
||||
private:
|
||||
Adafruit_GFX *_gfx;
|
||||
int16_t _x1, _y1; // Coordinates of top-left corner
|
||||
uint16_t _w, _h;
|
||||
uint8_t _textsize_x;
|
||||
uint8_t _textsize_y;
|
||||
uint16_t _outlinecolor, _fillcolor, _textcolor;
|
||||
char _label[10];
|
||||
|
||||
bool currstate, laststate;
|
||||
};
|
||||
|
||||
/// A GFX 1-bit canvas context for graphics
|
||||
class GFXcanvas1 : public Adafruit_GFX {
|
||||
public:
|
||||
GFXcanvas1(uint16_t w, uint16_t h, bool allocate_buffer = true);
|
||||
~GFXcanvas1(void);
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
void fillScreen(uint16_t color);
|
||||
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
bool getPixel(int16_t x, int16_t y) const;
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Get a pointer to the internal buffer memory
|
||||
@returns A pointer to the allocated buffer
|
||||
*/
|
||||
/**********************************************************************/
|
||||
uint8_t *getBuffer(void) const { return buffer; }
|
||||
|
||||
protected:
|
||||
bool getRawPixel(int16_t x, int16_t y) const;
|
||||
void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
uint8_t *buffer; ///< Raster data: no longer private, allow subclass access
|
||||
bool buffer_owned; ///< If true, destructor will free buffer, else it will do
|
||||
///< nothing
|
||||
|
||||
private:
|
||||
#ifdef __AVR__
|
||||
// Bitmask tables of 0x80>>X and ~(0x80>>X), because X>>Y is slow on AVR
|
||||
static const uint8_t PROGMEM GFXsetBit[], GFXclrBit[];
|
||||
#endif
|
||||
};
|
||||
|
||||
/// A GFX 8-bit canvas context for graphics
|
||||
class GFXcanvas8 : public Adafruit_GFX {
|
||||
public:
|
||||
GFXcanvas8(uint16_t w, uint16_t h, bool allocate_buffer = true);
|
||||
~GFXcanvas8(void);
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
void fillScreen(uint16_t color);
|
||||
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
uint8_t getPixel(int16_t x, int16_t y) const;
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Get a pointer to the internal buffer memory
|
||||
@returns A pointer to the allocated buffer
|
||||
*/
|
||||
/**********************************************************************/
|
||||
uint8_t *getBuffer(void) const { return buffer; }
|
||||
|
||||
protected:
|
||||
uint8_t getRawPixel(int16_t x, int16_t y) const;
|
||||
void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
uint8_t *buffer; ///< Raster data: no longer private, allow subclass access
|
||||
bool buffer_owned; ///< If true, destructor will free buffer, else it will do
|
||||
///< nothing
|
||||
};
|
||||
|
||||
/// A GFX 16-bit canvas context for graphics
|
||||
class GFXcanvas16 : public Adafruit_GFX {
|
||||
public:
|
||||
GFXcanvas16(uint16_t w, uint16_t h, bool allocate_buffer = true);
|
||||
~GFXcanvas16(void);
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
void fillScreen(uint16_t color);
|
||||
void byteSwap(void);
|
||||
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
uint16_t getPixel(int16_t x, int16_t y) const;
|
||||
/**********************************************************************/
|
||||
/*!
|
||||
@brief Get a pointer to the internal buffer memory
|
||||
@returns A pointer to the allocated buffer
|
||||
*/
|
||||
/**********************************************************************/
|
||||
uint16_t *getBuffer(void) const { return buffer; }
|
||||
|
||||
protected:
|
||||
uint16_t getRawPixel(int16_t x, int16_t y) const;
|
||||
void drawFastRawVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
void drawFastRawHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
uint16_t *buffer; ///< Raster data: no longer private, allow subclass access
|
||||
bool buffer_owned; ///< If true, destructor will free buffer, else it will do
|
||||
///< nothing
|
||||
};
|
||||
|
||||
#endif // _ADAFRUIT_GFX_H
|
||||
56
src/Resources/EEPROM.txt
Normal file
56
src/Resources/EEPROM.txt
Normal file
@@ -0,0 +1,56 @@
|
||||
// --- EEPROM --- //
|
||||
|
||||
// EEPROM is a static class. it does not need to be initiated or created
|
||||
// Each adress is 1 bytes in size. so if you store an int in adress 0, the first half will be in 0 and the second half will be stored in 1;
|
||||
// Also note, EEPROM has a limited life span. each adress can only be updates around 100k times. this sould like a lot, until you realise that the CPU clock speed is
|
||||
|
||||
EEPROM.length() -> returns number of unique adresses
|
||||
|
||||
EEPROM.get(INT address, ANY_OBJECT variableToBeAsigned)
|
||||
|
||||
EEPROM.read(INT address) -> reads a single byte
|
||||
|
||||
EEPROM.put(INT address, ANY_OBJECT variableToStore) -> Used to save multi-byte data to EEPROM. also works like .update
|
||||
|
||||
EEPROM.update(INT address, ANY_OBJECT variableToStore) -> check if the value in EEPROM address is different to
|
||||
"variableToStore", if so, update the value. This is
|
||||
to help maintain the life of EEPROM and mitiage un-nessersary ware
|
||||
|
||||
EEPROM.write() -> writes a single byte of data to said adress
|
||||
|
||||
|
||||
|
||||
|
||||
// --- Arduino --- //
|
||||
|
||||
// does not need any kind of class, is available from the getgo
|
||||
|
||||
tone(pin, frequency, duration) -> play a tone for "duration" miliseconds
|
||||
tone(pin, frequency) -> plays a tone indefinitly
|
||||
noTone(pin) -> stops the buzzer
|
||||
|
||||
|
||||
|
||||
|
||||
// --- GFX Library --- //
|
||||
|
||||
// needs to be created through constructor. input the width, height etc...
|
||||
|
||||
Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, &SPI, CS_PIN, DC_PIN, RST_PIN);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// --- RF24 --- //
|
||||
|
||||
// needs to be created through constructor
|
||||
|
||||
RF24 radio(RF_ENABLE_PIN, CSN_PIN) -> create a radio object
|
||||
|
||||
radio.begin() -> init the radio. returns false if it fails to start
|
||||
|
||||
radio.setPALevel(RF24_PA_LOW) -> able to set the volume ()
|
||||
|
||||
|
||||
radio.startListening(); // put radio in RX mode
|
||||
2563
src/Resources/RF24.h
Normal file
2563
src/Resources/RF24.h
Normal file
File diff suppressed because it is too large
Load Diff
82
src/Resources/ezButton.h
Normal file
82
src/Resources/ezButton.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2019, ArduinoGetStarted.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* - Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* - Neither the name of the ArduinoGetStarted.com nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ARDUINOGETSTARTED.COM "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ARDUINOGETSTARTED.COM BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef ezButton_h
|
||||
#define ezButton_h
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define COUNT_FALLING 0
|
||||
#define COUNT_RISING 1
|
||||
#define COUNT_BOTH 2
|
||||
|
||||
// Constants for button modes
|
||||
#define INTERNAL_PULLUP INPUT_PULLUP
|
||||
#ifdef INPUT_PULLDOWN
|
||||
#define INTERNAL_PULLDOWN INPUT_PULLDOWN
|
||||
#else
|
||||
#define INTERNAL_PULLDOWN INPUT
|
||||
#endif
|
||||
|
||||
#define EXTERNAL_PULLUP 0xFE
|
||||
#define EXTERNAL_PULLDOWN 0xFF
|
||||
|
||||
class ezButton
|
||||
{
|
||||
private:
|
||||
int btnPin;
|
||||
unsigned long debounceTime;
|
||||
unsigned long count;
|
||||
int countMode;
|
||||
int pressedState; // the state when the button is considered pressed
|
||||
int unpressedState; // the state when the button is considered unpressed
|
||||
|
||||
int previousSteadyState; // the previous steady state from the input pin, used to detect pressed and released event
|
||||
int lastSteadyState; // the last steady state from the input pin
|
||||
int lastFlickerableState; // the last flickerable state from the input pin
|
||||
|
||||
unsigned long lastDebounceTime; // the last time the output pin was toggled
|
||||
|
||||
public:
|
||||
ezButton(int pin);
|
||||
ezButton(int pin, int mode);
|
||||
void setDebounceTime(unsigned long time);
|
||||
int getState(void);
|
||||
int getStateRaw(void);
|
||||
bool isPressed(void);
|
||||
bool isReleased(void);
|
||||
void setCountMode(int mode);
|
||||
unsigned long getCount(void);
|
||||
void resetCount(void);
|
||||
void loop(void);
|
||||
};
|
||||
|
||||
#endif
|
||||
127
src/conversation_history.md
Normal file
127
src/conversation_history.md
Normal file
@@ -0,0 +1,127 @@
|
||||
# Conversation History
|
||||
|
||||
**User:** Is there a way I can view our conversation history?
|
||||
|
||||
**Gemini:** I do not have a command to view the conversation history. You should be able to scroll up in your terminal to see our previous messages.
|
||||
|
||||
**User:** Ah I'm looking for a conversation from yesterday. No worries
|
||||
|
||||
**Gemini:** Got it. Terminal scrollback usually doesn't persist between sessions.
|
||||
|
||||
I can save our conversations to a file for you to review later. Would you like me to set that up?
|
||||
|
||||
**User:** That's not a bad idea. what file type would you use?
|
||||
|
||||
**Gemini:** I would use a Markdown (`.md`) file.
|
||||
|
||||
This format is easy to read and is great for preserving the formatting of any code snippets we might discuss. I can name it `conversation_history.md`.
|
||||
|
||||
Does that sound good?
|
||||
|
||||
**User:** yeah that sounds good! also for a quick overview of the project, you can read "info.txt".
|
||||
|
||||
**Gemini:** Sounds good. I'll create `conversation_history.md` and start logging our conversation.
|
||||
|
||||
Thanks for the tip, I'll read `info.txt` now to get an overview of the project.
|
||||
|
||||
**User:** Please continue.
|
||||
|
||||
**Gemini:** Of course. Based on the `info.txt` file, I see that a "Calculator" program is on the list of required programs, but I don't see any corresponding files for it in the project structure.
|
||||
|
||||
I can start by creating the basic files for the calculator program:
|
||||
1. Create a `Programs/Calculator` directory.
|
||||
2. Create `Calculator.h` and `Calculator.cpp` inside the new directory.
|
||||
3. Add a basic class structure to these files.
|
||||
|
||||
After that, I can work on integrating it into the main menu.
|
||||
|
||||
Would you like me to proceed with creating these files?
|
||||
|
||||
**User:** yeah go for it!
|
||||
|
||||
**Gemini:** Great. I'll create the directory and the basic files for the calculator program.
|
||||
|
||||
**User:** sure
|
||||
|
||||
**Gemini:** Okay, I will now read `Menu.h` and `Menu.cpp`.
|
||||
|
||||
**User:** yeah looks good
|
||||
|
||||
**Gemini:** Alright, I'll start by updating the header file (`Calculator.h`) with the necessary variables for the UI and a private function to handle drawing. Then, I'll implement the initial drawing logic in `Calculator.cpp`.
|
||||
|
||||
This first step will just render the static UI on the screen. We'll handle input and logic next.
|
||||
|
||||
**User:** yeah sure
|
||||
|
||||
**Gemini:** Okay, I will now add the joystick handling logic to the `loop` function in `Calculator.cpp` to enable cursor movement. I'll use the same input detection method as the main menu to ensure consistent behavior.
|
||||
|
||||
**User:** I just had to quickly correct a typo. you put "Adafruit_SSD1151" in Calculator.cpp instead off 1351. easily done! other than that, the code succsesfully compiles! well done! Yes, you can proceed
|
||||
|
||||
**Gemini:** Thank you for catching that typo! I appreciate you fixing it and letting me know the code compiles. That's great news.
|
||||
|
||||
I will now proceed with implementing the button press logic as we discussed. I'll add the code to detect when the joystick button is released and print the selected grid item to the serial port for verification.
|
||||
|
||||
**User:** ok. I will test your implementation now
|
||||
|
||||
**Gemini:** Sounds good. I'll wait for your feedback.
|
||||
|
||||
**User:** that works suprising well. However, there are a couple of issues. the main one is that the screen is flickering a lot. also, The controls with the joystick are a bit inconsistent. for example I my push the joystick in one direction, but the computer may read multiple inputs in the wrong direction. This may be hardware limitaion and I may need to invest in a d-pad
|
||||
|
||||
**Gemini:** You've found some excellent points. Your analysis is spot on.
|
||||
|
||||
1. **Screen Flickering:** You are right, this is the main issue. It's happening because the code is clearing and redrawing the entire screen on every single frame. This is inefficient and a classic cause of flickering.
|
||||
2. **Joystick Input:** The input detection logic is quite simple. If the joystick hardware is a bit "noisy," it can definitely produce ghost inputs like you're seeing.
|
||||
|
||||
Let's tackle the flickering first, as that's a definite software bug I can fix.
|
||||
|
||||
I will modify the drawing code to only clear the top part of the screen where the numbers are displayed, rather than the whole screen. The rest of the UI will just be drawn over itself. This should eliminate the most noticeable flickering.
|
||||
|
||||
Shall I apply this fix?
|
||||
|
||||
**User:** yes please
|
||||
|
||||
**Gemini:** Okay, I'm applying the fix to reduce screen flickering now.
|
||||
|
||||
**User:** yes please
|
||||
|
||||
**Gemini:** The rendering fix has been applied. The button backgrounds should now correctly revert to black when the cursor moves away.
|
||||
|
||||
Please give it a test when you have a moment. Once you confirm it's working as expected, we can proceed with implementing the calculator's operator and equals logic.
|
||||
|
||||
**User:** Please continue.
|
||||
|
||||
**Gemini:** Understood. I will proceed with implementing the final piece of the calculator's functionality: the operator and equals buttons.
|
||||
|
||||
I will now modify the `handleButtonPress` function to perform the calculations.
|
||||
|
||||
**User:** no it's ok. One thing you could do that would be great is implement a draw keyboard method in the keyboard.cpp file
|
||||
|
||||
**Gemini:** Okay, I can definitely work on that.
|
||||
|
||||
I see the file `Programs/Keyboard.h`, but I don't see a corresponding `Keyboard.cpp` file. I'll need to create that file to implement the `drawKeyboard` method.
|
||||
|
||||
Before I start, I'll need to read `Keyboard.h` to understand the existing class structure. Shall I proceed with reading the header file?
|
||||
|
||||
**User:** ah, check now. I had create a keyboard.cpp but it was lowercase by mistake. there is a method called render in there. if you could implement it in there that would be fantastic
|
||||
|
||||
**Gemini:** Ah, I see it now. Thank you for clarifying. I can certainly implement the `render` method in `keyboard.cpp`.
|
||||
|
||||
For the keyboard layout, I propose a simple 6x5 grid to fit the screen and make navigation manageable:
|
||||
```
|
||||
[A][B][C][D][E][F]
|
||||
[G][H][I][J][K][L]
|
||||
[M][N][O][P][Q][R]
|
||||
[S][T][U][V][W][X]
|
||||
[Y][Z][.][<][ENT]
|
||||
```
|
||||
Here, `<` would be backspace and `ENT` would be enter. The `render` method would draw this grid, highlight the currently selected key, and show the composed text at the top of the screen.
|
||||
|
||||
Does this approach sound good? If you agree, I'll read the keyboard header and source files to begin the implementation.
|
||||
|
||||
**User:** yeah I like it
|
||||
|
||||
**Gemini:** Great. I'll read the `Keyboard.h` and `keyboard.cpp` files now to get started.
|
||||
|
||||
**User:** yeah I agree with that
|
||||
|
||||
**Gemini:** Excellent. I'll start by modifying `Keyboard.h` to update the `render` method and add the necessary variables to manage the keyboard's state, like the cursor position and the grid layout.
|
||||
27
src/info.txt
Normal file
27
src/info.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
--> Project Outline <--
|
||||
|
||||
Hardware:
|
||||
I am making a small, handheld 3d printed games console for my 7yo and 5yo cousins
|
||||
the console has a 128x128 colour OLED display, a 7 segment display, a basic speaker,
|
||||
two buttons and a joystick (with a built-in button). I also plan to make it battery powered too.
|
||||
The console will also have wireless capabilites by using the NFR24L01 radio transceiver module. this
|
||||
will the consoles to communicate and open the door to multiplayer games
|
||||
|
||||
The main board is a arduino nano R4. this has 256kb of programable memory, 32kb or ram and 8kb or EEPROM
|
||||
for storing save states.
|
||||
|
||||
Software:
|
||||
The computer needs to have a centeral "OS" that everything is based around. It need a menu to navigate
|
||||
and needs settings to the user can customise things.
|
||||
The OS will also have a top bar to give the user information about the deice such as battery level and time
|
||||
|
||||
Current List of Required Programs:
|
||||
- Calculator
|
||||
- Snake (single player and multiplayer, selected from within the game)
|
||||
- 2D puzzle maze (a 2d generated maze with a procedually generated puzzles to solve)
|
||||
- asteroids (single player and multiplayer. In multiplayer you can shoot eachother)
|
||||
- messenger (a way to send a text message to the other device. more for fun as it is short range)
|
||||
- chess (single player and multiplayer. You can also play against a basic AI)
|
||||
- 3D maze (may be out of the scope of this project)
|
||||
- more to come!
|
||||
|
||||
194
src/main.cpp
Normal file
194
src/main.cpp
Normal file
@@ -0,0 +1,194 @@
|
||||
#include <Arduino.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1351.h>
|
||||
#include <SPI.h>
|
||||
#include <ezButton.h>
|
||||
#include <EEPROM.h>
|
||||
#include "RF24.h"
|
||||
|
||||
// Screen dimensions
|
||||
#define SCREEN_WIDTH 128
|
||||
#define SCREEN_HEIGHT 128 // Change this to 96 for 1.27" OLED.
|
||||
|
||||
// You can use any (4 or) 5 pins
|
||||
#define SCLK_PIN 13
|
||||
#define MOSI_PIN 11
|
||||
#define MISO_PIN 12
|
||||
#define DC_PIN 9 // was pin 4
|
||||
#define CS_PIN 10 // was pin 5
|
||||
#define RST_PIN 8 // was pin 6
|
||||
|
||||
#define RF_CE_PIN 7 // (chicp enable)
|
||||
#define RF_CSN_PIN 6 // (SPI select)
|
||||
|
||||
// Control Data
|
||||
#define BUTTON_TOP 0
|
||||
#define BUTTON_BOTTOM 1
|
||||
#define JOYSTICK_BUTTON A4
|
||||
#define JOYSTICK_X A6
|
||||
#define JOYSTICK_Y A5
|
||||
|
||||
#include "Programs/Calculator/Calculator.h"
|
||||
#include "Programs/Snake/Snake.h"
|
||||
#include "Programs/Settings/Settings.h"
|
||||
#include "Programs/Asteroids/Asteroids.h"
|
||||
|
||||
#include "Bitmaps.h"
|
||||
#include "Menu.h"
|
||||
#include "utility.h"
|
||||
|
||||
Adafruit_SSD1351 tft = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, &SPI, CS_PIN, DC_PIN, RST_PIN);
|
||||
RF24 radio(RF_CE_PIN, RF_CSN_PIN);
|
||||
inputData userInputs(BUTTON_TOP, BUTTON_BOTTOM, JOYSTICK_BUTTON);
|
||||
//programID currentProgram = NO_PROGRAM;
|
||||
|
||||
unsigned long interval=1000; // the time we need to wait
|
||||
unsigned long previousMillis=0; // millis() returns an unsigned long.
|
||||
|
||||
Program* currentProgram = nullptr; // will be renamed to currentProgram when fully implemented
|
||||
Program* nextProgram = nullptr;
|
||||
|
||||
struct state {
|
||||
bool SoundEnabled = true;
|
||||
bool RunningProgram = false;
|
||||
bool InMenu = false;
|
||||
bool RadioEnabled = true;
|
||||
} MachineState;
|
||||
|
||||
|
||||
void displaySplashScreen(int duration);
|
||||
void getUserInput(inputData* inputs);
|
||||
void requestProgramChange(Program* program);
|
||||
void drawInfoBar();
|
||||
float normalizeJoystick(int analogValue);
|
||||
|
||||
|
||||
|
||||
void requestProgramChange(Program* program){
|
||||
nextProgram = program;
|
||||
}
|
||||
|
||||
// --- STARTUP -- //
|
||||
void setup(void) {
|
||||
Serial.begin(9600);
|
||||
Serial.println("Starting up...");
|
||||
userInputs.buttonTop.setDebounceTime(25);
|
||||
userInputs.buttonBottom.setDebounceTime(25);
|
||||
userInputs.joyStickButton.setDebounceTime(25);
|
||||
|
||||
tft.begin();
|
||||
|
||||
// spash screen goes here!
|
||||
displaySplashScreen(2000); // show spash for 2 seconds
|
||||
MachineState.InMenu = true;
|
||||
currentProgram = new Menu::Menu();
|
||||
currentProgram->onEnter(&tft);
|
||||
Serial.println("Start sucsessful");
|
||||
}
|
||||
|
||||
// --- PROGRAM LOOP --- //
|
||||
void loop() {
|
||||
// need to loop as fast a possible to maintain framerate and responce time
|
||||
unsigned long currentMillis = millis(); // grab current time
|
||||
|
||||
// handle program transistion
|
||||
if (nextProgram != nullptr) {
|
||||
if (currentProgram != nullptr) {
|
||||
currentProgram->onExit();
|
||||
delete currentProgram;
|
||||
}
|
||||
currentProgram = nextProgram;
|
||||
nextProgram = nullptr;
|
||||
if (currentProgram != nullptr){
|
||||
currentProgram->onEnter(&tft);
|
||||
}
|
||||
}
|
||||
|
||||
// update current program
|
||||
if (currentProgram != nullptr){
|
||||
getUserInput(&userInputs);
|
||||
currentProgram->loop(&tft, &userInputs);
|
||||
if (!currentProgram->disableInfoBar){ drawInfoBar(); }
|
||||
}
|
||||
|
||||
// check if "interval" time has passed (1000 milliseconds)
|
||||
if ((unsigned long)(currentMillis - previousMillis) >= interval) {
|
||||
// do task
|
||||
previousMillis = millis();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void getUserInput(inputData *inputs){
|
||||
// Call the loop() function for each button. This is required by ezButton.
|
||||
inputs->buttonTop.loop();
|
||||
inputs->buttonBottom.loop();
|
||||
inputs->joyStickButton.loop();
|
||||
|
||||
// The rest of the code can now get button states directly, e.g.:
|
||||
// if (inputs->buttonTop.isPressed()) { ... }
|
||||
|
||||
// For now, let's keep joystick values simple
|
||||
int rawX = analogRead(JOYSTICK_X);
|
||||
int rawY = analogRead(JOYSTICK_Y);
|
||||
inputs->joyX = normalizeJoystick(rawX);
|
||||
inputs->joyY = normalizeJoystick(rawY);
|
||||
|
||||
|
||||
inputs->joystickCommand = COMMAND_NO;
|
||||
|
||||
// check left/right commands
|
||||
if (rawX < LEFT_THRESHOLD){
|
||||
inputs->joystickCommand = inputs->joystickCommand | COMMAND_LEFT;
|
||||
}
|
||||
else if (rawX > RIGHT_THRESHOLD){
|
||||
inputs->joystickCommand = inputs->joystickCommand | COMMAND_RIGHT;
|
||||
}
|
||||
|
||||
// check up/down commands
|
||||
if (rawY < UP_THRESHOLD){
|
||||
inputs->joystickCommand = inputs->joystickCommand | COMMAND_UP;
|
||||
}
|
||||
else if (rawY > DOWN_THRESHOLD){
|
||||
inputs->joystickCommand = inputs->joystickCommand | COMMAND_DOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void displaySplashScreen(int duration){
|
||||
// - could play a tune and also show off the capability of the display with some
|
||||
// stylish graphics! maybe even 3d graphics if build a library for it
|
||||
tft.fillScreen(BLACK);
|
||||
tft.drawBitmap(0, 0, spash_screen_BMP, 128, 128, WHITE);
|
||||
tft.setCursor(10, 10);
|
||||
tft.setTextColor(GREEN);
|
||||
tft.println(F("B-TEK Advanced"));
|
||||
tft.setCursor(30, 10);
|
||||
tft.println(F("Booting in progress..."));
|
||||
delay(duration);
|
||||
tft.fillScreen(BLACK);
|
||||
}
|
||||
|
||||
|
||||
void drawInfoBar(){
|
||||
// a bar on the time with data like battery life and current time and wifi status... maybe more (:
|
||||
tft.drawRect(0, 0, 128, 12, RED);
|
||||
tft.setCursor(5, 2);
|
||||
tft.setTextSize(1);
|
||||
tft.setTextColor(WHITE);
|
||||
tft.println(F("20:34"));
|
||||
tft.setCursor(90, 2);
|
||||
tft.println(F("[-->]"));
|
||||
}
|
||||
|
||||
|
||||
float normalizeJoystick(int analogValue) {
|
||||
// Account for the dead zone
|
||||
if (abs(analogValue - 512) < JOY_DEAD_ZONE) {
|
||||
return 0.0;
|
||||
}
|
||||
// Shift the range so the center is 0
|
||||
float shiftedValue = analogValue - 512;
|
||||
|
||||
return shiftedValue / 512.0;
|
||||
}
|
||||
20
src/main.cpp.bak
Normal file
20
src/main.cpp.bak
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <Arduino.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1351.h>
|
||||
#include <SPI.h>
|
||||
#include <ezButton.h>
|
||||
#include <EEPROM.h>
|
||||
#include "RF24.h"
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
delay(1000);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
delay(1000);
|
||||
}
|
||||
2
src/utility.cpp
Normal file
2
src/utility.cpp
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "utility.h"
|
||||
|
||||
81
src/utility.h
Normal file
81
src/utility.h
Normal file
@@ -0,0 +1,81 @@
|
||||
#pragma once
|
||||
|
||||
#define LEFT_THRESHOLD 400
|
||||
#define RIGHT_THRESHOLD 800
|
||||
#define UP_THRESHOLD 400
|
||||
#define DOWN_THRESHOLD 800
|
||||
|
||||
#define COMMAND_NO 0x00
|
||||
#define COMMAND_LEFT 0x01
|
||||
#define COMMAND_RIGHT 0x02
|
||||
#define COMMAND_UP 0x04
|
||||
#define COMMAND_DOWN 0x08
|
||||
|
||||
#include <ezButton.h>
|
||||
#include <Adafruit_SSD1351.h>
|
||||
|
||||
|
||||
// Color definitions
|
||||
static const int BLACK = 0x0000;
|
||||
static const int BLUE = 0x001F;
|
||||
static const int RED = 0xF800;
|
||||
static const int GREEN = 0x07E0;
|
||||
static const int CYAN = 0x07FF;
|
||||
static const int MAGENTA = 0xF81F;
|
||||
static const int YELLOW = 0xFFE0;
|
||||
static const int WHITE = 0xFFFF;
|
||||
|
||||
|
||||
static const int NOTE_A = 250; // hz
|
||||
static const int NOTE_B = 250; // hz
|
||||
static const int NOTE_C = 250; // hz
|
||||
static const int NOTE_D = 250; // hz
|
||||
static const int NOTE_E = 250; // hz
|
||||
static const int NOTE_F = 250; // hz
|
||||
static const int NOTE_G = 250; // hz
|
||||
|
||||
struct inputData {
|
||||
ezButton buttonTop;
|
||||
ezButton buttonBottom;
|
||||
ezButton joyStickButton;
|
||||
|
||||
float joyX = 0; // between -1 and 1
|
||||
float joyY = 0; // between -1 and 1
|
||||
|
||||
int joystickCommand = 0x00;
|
||||
|
||||
// Constructor
|
||||
inputData(int topPin, int bottomPin, int stickPin)
|
||||
: buttonTop(topPin),
|
||||
buttonBottom(bottomPin),
|
||||
joyStickButton(stickPin){
|
||||
}
|
||||
};
|
||||
|
||||
enum programID{
|
||||
NO_PROGRAM,
|
||||
PROGRAM_SNAKE,
|
||||
PROGRAM_MUSIC_MAKER,
|
||||
PROGRAM_SETTINGS,
|
||||
PROGRAM_ABOUT,
|
||||
PROGRAM_INFO,
|
||||
PROGRAM_WIRELESS,
|
||||
PROGRAM_MENU
|
||||
};
|
||||
|
||||
class Program {
|
||||
public:
|
||||
virtual void setup();
|
||||
virtual void loop(Adafruit_SSD1351 *tft, inputData *userInput);
|
||||
virtual void onEnter(Adafruit_SSD1351 *tft);
|
||||
virtual void onExit();
|
||||
|
||||
bool disableInfoBar = false;
|
||||
int framerate = 30;
|
||||
|
||||
// need to be able to set a framerate
|
||||
// need to be able to input comuncation data
|
||||
};
|
||||
|
||||
static const int JOY_DEAD_ZONE = 20;
|
||||
|
||||
Reference in New Issue
Block a user