arduino stuffs
start work on mp3player
| -rw-r--r-- | .clang-format | 2 | ||||
| -rw-r--r-- | .gitignore | 1 | ||||
| m--------- | car_driver/godot/godot-cpp | 0 | ||||
| -rw-r--r-- | mp3player/arduino/arduino.ino | 10 | ||||
| -rw-r--r-- | mp3player/arduino/display/display.h | 68 | ||||
| -rw-r--r-- | mp3player/arduino/display/freeserif.h | 163 | ||||
| -rw-r--r-- | mp3player/arduino/display/splash.h | 45 | ||||
| -rw-r--r-- | mp3player/arduino/error.h | 29 | ||||
| -rw-r--r-- | mp3player/arduino/player.h | 26 | ||||
| -rw-r--r-- | sizer/sizer.ino | 29 |
10 files changed, 344 insertions, 29 deletions
diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..0ce596c --- /dev/null +++ b/.clang-format @@ -0,0 +1,2 @@ +BreakBeforeBraces: Attach +ColumnLimit: 115 @@ -3,3 +3,4 @@ libraries/ car_driver/godot/car_driver/.import/ *.os *.dblite +tmp/ diff --git a/car_driver/godot/godot-cpp b/car_driver/godot/godot-cpp -Subproject 2b9843d573b6852610a2bb0cc683d3167c79054 +Subproject 97c181a2461e590affab4c32638ca01928999db diff --git a/mp3player/arduino/arduino.ino b/mp3player/arduino/arduino.ino new file mode 100644 index 0000000..6cf8ad0 --- /dev/null +++ b/mp3player/arduino/arduino.ino @@ -0,0 +1,10 @@ +#include "display/display.h" +#include "player.h" + +void setup() { + Serial.begin(9600); + OLED::begin(); + Player::begin(); +} + +void loop() {} diff --git a/mp3player/arduino/display/display.h b/mp3player/arduino/display/display.h new file mode 100644 index 0000000..2445934 --- /dev/null +++ b/mp3player/arduino/display/display.h @@ -0,0 +1,68 @@ +#ifndef DISPLAY_H +#define DISPLAY_H + +#define SCREEN_WIDTH 128 +#define SCREEN_HEIGHT 64 + +#include "freeserif.h" +#include "splash.h" +#include <Adafruit_SSD1306.h> +#include <Wire.h> + +static inline float lerp(float from, float to, float weight) { return from + (to - from) * weight; } + +namespace OLED { + +Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); + +inline void print(const String s) { oled.print(s); } +inline void println(const String s) { oled.println(s); } +inline void clear() { oled.clearDisplay(); } +inline void flush() { oled.display(); } + +// Adafruit_GFX::drawBitmap(..., size_x, size_y). adds multiplication factors +void draw_bitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint8_t size_x, + uint8_t size_y) { + int16_t i, j, byteWidth = (w + 7) / 8; + + for (j = 0; j < h; j++) + for (i = 0; i < w; i++) + if (pgm_read_byte(bitmap + j * byteWidth + i / 8) & (128 >> (i & 7))) { + if (size_x == 0 && size_y == 0) + oled.drawPixel(x + i, y + j, color); + else + oled.drawRect(x + i * size_x, y + j * size_y, size_x, size_y, color); + } +} + +#define SPLASH_SCALE 2 +#define SPLASH_BOTTOM (SCREEN_HEIGHT - SPLASH_SIZE) * (SPLASH_SCALE * SPLASH_SCALE) +#define SPLASH_MIDDLE SCREEN_WIDTH / SPLASH_SCALE - SPLASH_SIZE + +void show_splash() { + for (unsigned int c = 0; c < 2; c++) { + for (unsigned int i = 0; i < 9; i++) { + clear(); + const int16_t y_pos = lerp(SPLASH_BOTTOM, 0 - (SPLASH_SIZE * SPLASH_SCALE) - 30, (i + 1) / 10.); + const int16_t x_pos = (rand() % 10 - 5) + SPLASH_MIDDLE; + draw_bitmap(x_pos, y_pos, ships[i], SPLASH_SIZE, SPLASH_SIZE, WHITE, SPLASH_SCALE, SPLASH_SCALE); + flush(); + delay(20); + } + delay(40); + } +} + +// boot oled +void begin() { + oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); + oled.clearDisplay(); + oled.setFont(&FreeSerif9pt7b); + oled.setTextSize(1); + oled.setTextColor(SSD1306_WHITE); + oled.setCursor(0, 15); + show_splash(); +} + +} // namespace OLED +#endif
\ No newline at end of file diff --git a/mp3player/arduino/display/freeserif.h b/mp3player/arduino/display/freeserif.h new file mode 100644 index 0000000..0d56608 --- /dev/null +++ b/mp3player/arduino/display/freeserif.h @@ -0,0 +1,163 @@ +#include <gfxfont.h> +const uint8_t FreeSerif9pt7bBitmaps[] PROGMEM = { + 0xFF, 0xEA, 0x03, 0xDE, 0xF7, 0x20, 0x11, 0x09, 0x04, 0x82, 0x4F, 0xF9, 0x10, 0x89, 0xFF, 0x24, 0x12, 0x09, + 0x0C, 0x80, 0x10, 0x7C, 0xD6, 0xD2, 0xD0, 0xF0, 0x38, 0x1E, 0x17, 0x93, 0x93, 0xD6, 0x7C, 0x10, 0x38, 0x43, + 0x3C, 0x39, 0x21, 0x8A, 0x0C, 0x50, 0x65, 0x39, 0xCB, 0x20, 0xB9, 0x05, 0x88, 0x4C, 0x44, 0x64, 0x21, 0xC0, + 0x0E, 0x00, 0xC8, 0x06, 0x40, 0x32, 0x01, 0xA0, 0x07, 0x78, 0x31, 0x87, 0x88, 0x46, 0x86, 0x34, 0x30, 0xC1, + 0xC7, 0x17, 0xCF, 0x00, 0xFE, 0x08, 0x88, 0x84, 0x63, 0x18, 0xC6, 0x10, 0x82, 0x08, 0x20, 0x82, 0x08, 0x21, + 0x0C, 0x63, 0x18, 0xC4, 0x22, 0x22, 0x00, 0x63, 0x9A, 0xDC, 0x72, 0xB6, 0x08, 0x08, 0x04, 0x02, 0x01, 0x0F, + 0xF8, 0x40, 0x20, 0x10, 0x08, 0x00, 0xD8, 0xF0, 0xF0, 0x08, 0x84, 0x22, 0x10, 0x8C, 0x42, 0x31, 0x00, 0x1C, + 0x31, 0x98, 0xD8, 0x3C, 0x1E, 0x0F, 0x07, 0x83, 0xC1, 0xE0, 0xD8, 0xC4, 0x61, 0xC0, 0x13, 0x8C, 0x63, 0x18, + 0xC6, 0x31, 0x8C, 0x67, 0x80, 0x3C, 0x4E, 0x86, 0x06, 0x06, 0x04, 0x0C, 0x08, 0x10, 0x20, 0x41, 0xFE, 0x3C, + 0xC6, 0x06, 0x04, 0x1C, 0x3E, 0x07, 0x03, 0x03, 0x03, 0x06, 0xF8, 0x04, 0x18, 0x71, 0x64, 0xC9, 0xA3, 0x46, + 0xFE, 0x18, 0x30, 0x60, 0x0F, 0x10, 0x20, 0x3C, 0x0E, 0x07, 0x03, 0x03, 0x03, 0x02, 0x04, 0xF8, 0x07, 0x1C, + 0x30, 0x60, 0x60, 0xDC, 0xE6, 0xC3, 0xC3, 0xC3, 0x43, 0x66, 0x3C, 0x7F, 0x82, 0x02, 0x02, 0x04, 0x04, 0x04, + 0x08, 0x08, 0x08, 0x10, 0x10, 0x3C, 0x8F, 0x1E, 0x3E, 0x4F, 0x06, 0x36, 0xC7, 0x8F, 0x1B, 0x33, 0xC0, 0x3C, + 0x66, 0xC2, 0xC3, 0xC3, 0xC3, 0xC3, 0x63, 0x3F, 0x06, 0x06, 0x0C, 0x38, 0x60, 0xF0, 0x0F, 0xD8, 0x00, 0x03, + 0x28, 0x01, 0x87, 0x0E, 0x1C, 0x0C, 0x03, 0x80, 0x70, 0x0E, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x00, 0x0F, 0xF8, + 0x80, 0x1C, 0x01, 0xC0, 0x1C, 0x01, 0xC0, 0xE0, 0xE0, 0xE0, 0xC0, 0x00, 0x79, 0x1A, 0x18, 0x30, 0x60, 0x83, + 0x04, 0x10, 0x20, 0x40, 0x03, 0x00, 0x0F, 0x83, 0x8C, 0x60, 0x26, 0x02, 0xC7, 0x9C, 0xC9, 0xD8, 0x9D, 0x99, + 0xD9, 0x26, 0xEC, 0x60, 0x03, 0x04, 0x0F, 0x80, 0x02, 0x00, 0x10, 0x01, 0xC0, 0x16, 0x00, 0x98, 0x04, 0xC0, + 0x43, 0x03, 0xF8, 0x20, 0x61, 0x03, 0x18, 0x1D, 0xE1, 0xF0, 0xFF, 0x86, 0x1C, 0xC1, 0x98, 0x33, 0x0C, 0x7E, + 0x0C, 0x31, 0x83, 0x30, 0x66, 0x0C, 0xC3, 0x7F, 0xC0, 0x1F, 0x26, 0x1D, 0x81, 0xE0, 0x1C, 0x01, 0x80, 0x30, + 0x06, 0x00, 0xC0, 0x0C, 0x00, 0xC1, 0x8F, 0xC0, 0xFF, 0x03, 0x1C, 0x30, 0x63, 0x07, 0x30, 0x33, 0x03, 0x30, + 0x33, 0x03, 0x30, 0x33, 0x06, 0x30, 0xCF, 0xF0, 0xFF, 0x98, 0x26, 0x01, 0x80, 0x61, 0x1F, 0xC6, 0x11, 0x80, + 0x60, 0x18, 0x16, 0x0F, 0xFE, 0xFF, 0xB0, 0x58, 0x0C, 0x06, 0x13, 0xF9, 0x84, 0xC0, 0x60, 0x30, 0x18, 0x1E, + 0x00, 0x1F, 0x23, 0x0E, 0x60, 0x26, 0x00, 0xC0, 0x0C, 0x0F, 0xC0, 0x6C, 0x06, 0xC0, 0x66, 0x06, 0x30, 0x60, + 0xF8, 0xF1, 0xEC, 0x19, 0x83, 0x30, 0x66, 0x0C, 0xFF, 0x98, 0x33, 0x06, 0x60, 0xCC, 0x19, 0x83, 0x78, 0xF0, + 0xF6, 0x66, 0x66, 0x66, 0x66, 0x6F, 0x3C, 0x61, 0x86, 0x18, 0x61, 0x86, 0x18, 0x6D, 0xBC, 0xF3, 0xE6, 0x08, + 0x61, 0x06, 0x20, 0x64, 0x07, 0x80, 0x6C, 0x06, 0x60, 0x63, 0x06, 0x18, 0x60, 0xCF, 0x3F, 0xF0, 0x18, 0x06, + 0x01, 0x80, 0x60, 0x18, 0x06, 0x01, 0x80, 0x60, 0x18, 0x16, 0x0B, 0xFE, 0xF0, 0x0E, 0x70, 0x38, 0xE0, 0x71, + 0xE1, 0x62, 0xC2, 0xC5, 0xC9, 0x89, 0x93, 0x13, 0x26, 0x23, 0x8C, 0x47, 0x18, 0x84, 0x33, 0x88, 0xF0, 0xE0, + 0xEE, 0x09, 0xC1, 0x2C, 0x25, 0xC4, 0x9C, 0x91, 0x92, 0x1A, 0x41, 0xC8, 0x19, 0x03, 0x70, 0x20, 0x1F, 0x06, + 0x31, 0x83, 0x20, 0x2C, 0x07, 0x80, 0xF0, 0x1E, 0x03, 0xC0, 0x68, 0x09, 0x83, 0x18, 0xC1, 0xF0, 0xFE, 0x31, + 0x98, 0x6C, 0x36, 0x1B, 0x19, 0xF8, 0xC0, 0x60, 0x30, 0x18, 0x1E, 0x00, 0x1F, 0x06, 0x31, 0x83, 0x20, 0x2C, + 0x07, 0x80, 0xF0, 0x1E, 0x03, 0xC0, 0x68, 0x19, 0x83, 0x18, 0xC0, 0xE0, 0x0E, 0x00, 0xE0, 0x07, 0xFE, 0x0C, + 0x61, 0x86, 0x30, 0xC6, 0x18, 0xC6, 0x1F, 0x83, 0x70, 0x67, 0x0C, 0x71, 0x87, 0x78, 0x70, 0x1D, 0x31, 0x98, + 0x4C, 0x07, 0x80, 0xE0, 0x1C, 0x07, 0x01, 0xA0, 0xD8, 0xCB, 0xC0, 0xFF, 0xF8, 0xCE, 0x18, 0x83, 0x00, 0x60, + 0x0C, 0x01, 0x80, 0x30, 0x06, 0x00, 0xC0, 0x18, 0x07, 0x80, 0xF0, 0xEC, 0x09, 0x81, 0x30, 0x26, 0x04, 0xC0, + 0x98, 0x13, 0x02, 0x60, 0x4C, 0x08, 0xC2, 0x0F, 0x80, 0xF8, 0x77, 0x02, 0x30, 0x23, 0x04, 0x18, 0x41, 0x84, + 0x0C, 0x80, 0xC8, 0x07, 0x00, 0x70, 0x02, 0x00, 0x20, 0xFB, 0xE7, 0xB0, 0xC0, 0x8C, 0x20, 0x86, 0x18, 0x41, + 0x8C, 0x40, 0xCB, 0x20, 0x65, 0x90, 0x1A, 0x70, 0x0E, 0x38, 0x03, 0x1C, 0x01, 0x04, 0x00, 0x82, 0x00, 0xFC, + 0xF9, 0x83, 0x06, 0x10, 0x19, 0x00, 0xD0, 0x03, 0x00, 0x1C, 0x01, 0x30, 0x11, 0xC1, 0x86, 0x08, 0x19, 0xE3, + 0xF0, 0xF8, 0xF6, 0x06, 0x30, 0x41, 0x88, 0x1D, 0x00, 0xD0, 0x06, 0x00, 0x60, 0x06, 0x00, 0x60, 0x06, 0x00, + 0xF0, 0x3F, 0xCC, 0x11, 0x06, 0x01, 0x80, 0x70, 0x0C, 0x03, 0x00, 0xE0, 0x38, 0x06, 0x05, 0xC1, 0x7F, 0xE0, + 0xFB, 0x6D, 0xB6, 0xDB, 0x6D, 0xB8, 0x82, 0x10, 0x82, 0x10, 0x86, 0x10, 0x86, 0x10, 0xED, 0xB6, 0xDB, 0x6D, + 0xB6, 0xF8, 0x18, 0x1C, 0x34, 0x26, 0x62, 0x42, 0xC1, 0xFF, 0x80, 0x84, 0x20, 0x79, 0x98, 0x30, 0xE6, 0xD9, + 0xB3, 0x3F, 0x20, 0x70, 0x18, 0x0C, 0x06, 0x03, 0x71, 0xCC, 0xC3, 0x61, 0xB0, 0xD8, 0x6C, 0x63, 0xE0, 0x3C, + 0xCF, 0x06, 0x0C, 0x18, 0x18, 0x9E, 0x01, 0x03, 0x80, 0xC0, 0x60, 0x31, 0xD9, 0x9D, 0x86, 0xC3, 0x61, 0xB0, + 0xCC, 0x63, 0xF0, 0x3C, 0x46, 0xFE, 0xC0, 0xC0, 0xE1, 0x62, 0x3C, 0x1E, 0x41, 0x83, 0x06, 0x1E, 0x18, 0x30, + 0x60, 0xC1, 0x83, 0x0F, 0x00, 0x3C, 0x19, 0xF6, 0x31, 0x8C, 0x1E, 0x08, 0x04, 0x01, 0xFC, 0x40, 0xB0, 0x2E, + 0x11, 0xF8, 0x20, 0x70, 0x18, 0x0C, 0x06, 0x03, 0x71, 0xCC, 0xC6, 0x63, 0x31, 0x98, 0xCC, 0x6F, 0x78, 0x60, + 0x02, 0xE6, 0x66, 0x66, 0xF0, 0x18, 0x00, 0x33, 0x8C, 0x63, 0x18, 0xC6, 0x31, 0x8B, 0x80, 0x20, 0x70, 0x18, + 0x0C, 0x06, 0x03, 0x3D, 0x88, 0xD8, 0x78, 0x36, 0x19, 0x8C, 0x6F, 0x78, 0x2E, 0x66, 0x66, 0x66, 0x66, 0x66, + 0xF0, 0xEE, 0x71, 0xCE, 0x66, 0x31, 0x98, 0xC6, 0x63, 0x19, 0x8C, 0x66, 0x31, 0xBD, 0xEF, 0xEE, 0x39, 0x98, + 0xCC, 0x66, 0x33, 0x19, 0x8D, 0xEF, 0x3E, 0x31, 0xB0, 0x78, 0x3C, 0x1E, 0x0D, 0x8C, 0x7C, 0xEE, 0x39, 0x98, + 0x6C, 0x36, 0x1B, 0x0D, 0x8C, 0xFC, 0x60, 0x30, 0x18, 0x1E, 0x00, 0x3D, 0x31, 0xB0, 0xD8, 0x6C, 0x36, 0x1B, + 0x8C, 0xFE, 0x03, 0x01, 0x80, 0xC0, 0xF0, 0x6D, 0xC6, 0x18, 0x61, 0x86, 0x3C, 0x76, 0x38, 0x58, 0x3E, 0x38, + 0xFE, 0x27, 0x98, 0xC6, 0x31, 0x8C, 0x38, 0xE7, 0x31, 0x98, 0xCC, 0x66, 0x33, 0x19, 0x8C, 0x7F, 0xF3, 0x61, + 0x22, 0x32, 0x14, 0x1C, 0x08, 0x08, 0xEF, 0x36, 0x61, 0x62, 0x22, 0x32, 0x35, 0x41, 0x9C, 0x18, 0x81, 0x08, + 0xF7, 0x12, 0x0E, 0x03, 0x01, 0xC1, 0x21, 0x09, 0xCF, 0xF3, 0x61, 0x62, 0x32, 0x34, 0x14, 0x1C, 0x08, 0x08, + 0x08, 0x10, 0xE0, 0xFD, 0x18, 0x60, 0x83, 0x0C, 0x70, 0xFE, 0x19, 0x8C, 0x63, 0x18, 0xC4, 0x61, 0x8C, 0x63, + 0x18, 0xC3, 0xFF, 0xF0, 0xC3, 0x18, 0xC6, 0x31, 0x84, 0x33, 0x18, 0xC6, 0x31, 0x98, 0x70, 0x24, 0xC1, 0xC0}; + +const GFXglyph FreeSerif9pt7bGlyphs[] PROGMEM = {{0, 0, 0, 5, 0, 1}, // 0x20 ' ' + {0, 2, 12, 6, 2, -11}, // 0x21 '!' + {3, 5, 4, 7, 1, -11}, // 0x22 '"' + {6, 9, 12, 9, 0, -11}, // 0x23 '#' + {20, 8, 14, 9, 1, -12}, // 0x24 '$' + {34, 13, 12, 15, 1, -11}, // 0x25 '%' + {54, 13, 13, 14, 1, -12}, // 0x26 '&' + {76, 2, 4, 4, 1, -11}, // 0x27 ''' + {77, 5, 15, 6, 1, -11}, // 0x28 '(' + {87, 5, 15, 6, 0, -11}, // 0x29 ')' + {97, 6, 8, 9, 3, -11}, // 0x2A '*' + {103, 9, 9, 10, 0, -8}, // 0x2B '+' + {114, 2, 3, 4, 2, 0}, // 0x2C ',' + {115, 4, 1, 6, 1, -3}, // 0x2D '-' + {116, 2, 2, 5, 1, -1}, // 0x2E '.' + {117, 5, 12, 5, 0, -11}, // 0x2F '/' + {125, 9, 13, 9, 0, -12}, // 0x30 '0' + {140, 5, 13, 9, 2, -12}, // 0x31 '1' + {149, 8, 12, 9, 1, -11}, // 0x32 '2' + {161, 8, 12, 9, 0, -11}, // 0x33 '3' + {173, 7, 12, 9, 1, -11}, // 0x34 '4' + {184, 8, 12, 9, 0, -11}, // 0x35 '5' + {196, 8, 13, 9, 1, -12}, // 0x36 '6' + {209, 8, 12, 9, 0, -11}, // 0x37 '7' + {221, 7, 13, 9, 1, -12}, // 0x38 '8' + {233, 8, 14, 9, 1, -12}, // 0x39 '9' + {247, 2, 8, 5, 1, -7}, // 0x3A ':' + {249, 3, 10, 5, 1, -7}, // 0x3B ';' + {253, 9, 9, 10, 1, -8}, // 0x3C '<' + {264, 9, 5, 10, 1, -6}, // 0x3D '=' + {270, 10, 9, 10, 0, -8}, // 0x3E '>' + {282, 7, 13, 8, 1, -12}, // 0x3F '?' + {294, 12, 13, 16, 2, -12}, // 0x40 '@' + {314, 13, 12, 13, 0, -11}, // 0x41 'A' + {334, 11, 12, 11, 0, -11}, // 0x42 'B' + {351, 11, 12, 12, 1, -11}, // 0x43 'C' + {368, 12, 12, 13, 0, -11}, // 0x44 'D' + {386, 10, 12, 11, 1, -11}, // 0x45 'E' + {401, 9, 12, 10, 1, -11}, // 0x46 'F' + {415, 12, 12, 13, 1, -11}, // 0x47 'G' + {433, 11, 12, 13, 1, -11}, // 0x48 'H' + {450, 4, 12, 6, 1, -11}, // 0x49 'I' + {456, 6, 12, 7, 0, -11}, // 0x4A 'J' + {465, 12, 12, 13, 1, -11}, // 0x4B 'K' + {483, 10, 12, 11, 1, -11}, // 0x4C 'L' + {498, 15, 12, 16, 0, -11}, // 0x4D 'M' + {521, 11, 12, 13, 1, -11}, // 0x4E 'N' + {538, 11, 13, 13, 1, -12}, // 0x4F 'O' + {556, 9, 12, 10, 1, -11}, // 0x50 'P' + {570, 11, 16, 13, 1, -12}, // 0x51 'Q' + {592, 11, 12, 12, 1, -11}, // 0x52 'R' + {609, 9, 12, 10, 0, -11}, // 0x53 'S' + {623, 11, 12, 11, 0, -11}, // 0x54 'T' + {640, 11, 12, 13, 1, -11}, // 0x55 'U' + {657, 12, 12, 13, 0, -11}, // 0x56 'V' + {675, 17, 12, 17, 0, -11}, // 0x57 'W' + {701, 13, 12, 13, 0, -11}, // 0x58 'X' + {721, 12, 12, 13, 0, -11}, // 0x59 'Y' + {739, 11, 12, 11, 0, -11}, // 0x5A 'Z' + {756, 3, 15, 6, 2, -11}, // 0x5B '[' + {762, 5, 12, 5, 0, -11}, // 0x5C '\' + {770, 3, 15, 6, 1, -11}, // 0x5D ']' + {776, 8, 7, 8, 0, -11}, // 0x5E '^' + {783, 9, 1, 9, 0, 2}, // 0x5F '_' + {785, 4, 3, 5, 0, -11}, // 0x60 '`' + {787, 7, 8, 8, 1, -7}, // 0x61 'a' + {794, 9, 13, 9, 0, -12}, // 0x62 'b' + {809, 7, 8, 8, 0, -7}, // 0x63 'c' + {816, 9, 13, 9, 0, -12}, // 0x64 'd' + {831, 8, 8, 8, 0, -7}, // 0x65 'e' + {839, 7, 13, 7, 1, -12}, // 0x66 'f' + {851, 10, 12, 8, 0, -7}, // 0x67 'g' + {866, 9, 13, 9, 0, -12}, // 0x68 'h' + {881, 4, 11, 5, 1, -10}, // 0x69 'i' + {887, 5, 15, 6, 0, -10}, // 0x6A 'j' + {897, 9, 13, 9, 1, -12}, // 0x6B 'k' + {912, 4, 13, 5, 1, -12}, // 0x6C 'l' + {919, 14, 8, 14, 0, -7}, // 0x6D 'm' + {933, 9, 8, 9, 0, -7}, // 0x6E 'n' + {942, 9, 8, 9, 0, -7}, // 0x6F 'o' + {951, 9, 12, 9, 0, -7}, // 0x70 'p' + {965, 9, 12, 9, 0, -7}, // 0x71 'q' + {979, 6, 8, 6, 0, -7}, // 0x72 'r' + {985, 6, 8, 7, 1, -7}, // 0x73 's' + {991, 5, 9, 5, 0, -8}, // 0x74 't' + {997, 9, 8, 9, 0, -7}, // 0x75 'u' + {1006, 8, 8, 8, 0, -7}, // 0x76 'v' + {1014, 12, 8, 12, 0, -7}, // 0x77 'w' + {1026, 9, 8, 9, 0, -7}, // 0x78 'x' + {1035, 8, 12, 8, 0, -7}, // 0x79 'y' + {1047, 7, 8, 7, 1, -7}, // 0x7A 'z' + {1054, 5, 16, 9, 1, -12}, // 0x7B '{' + {1064, 1, 12, 4, 1, -11}, // 0x7C '|' + {1066, 5, 16, 9, 3, -11}, // 0x7D '}' + {1076, 9, 3, 9, 0, -5}}; // 0x7E '~' + +const GFXfont FreeSerif9pt7b PROGMEM = {(uint8_t *)FreeSerif9pt7bBitmaps, (GFXglyph *)FreeSerif9pt7bGlyphs, 0x20, + 0x7E, 22}; + +// Approx. 1752 bytes diff --git a/mp3player/arduino/display/splash.h b/mp3player/arduino/display/splash.h new file mode 100644 index 0000000..8fb2c44 --- /dev/null +++ b/mp3player/arduino/display/splash.h @@ -0,0 +1,45 @@ +// ship 1-9, 16x16px animation, 432 bytes +#ifndef SPLASH_H +#define SPLASH_H + +#define SPLASH_SIZE 16 + +const unsigned char ship1[] PROGMEM = {0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x03, 0xc0, 0x03, 0xc0, 0x02, + 0x40, 0x06, 0x60, 0x0e, 0x70, 0x1f, 0xf8, 0x3f, 0xfc, 0x3f, 0xfc, + 0x3f, 0xfc, 0x03, 0xc0, 0x0f, 0xf0, 0x0e, 0xd0, 0x00, 0x00}; + +const unsigned char ship2[] PROGMEM = {0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x03, 0xc0, 0x03, 0xc0, 0x03, + 0x00, 0x07, 0x20, 0x0f, 0x30, 0x0f, 0xf0, 0x3f, 0xf4, 0x3f, 0xf4, + 0x3f, 0xf4, 0x01, 0x80, 0x0f, 0xf0, 0x07, 0x70, 0x00, 0x00}; + +const unsigned char ship3[] PROGMEM = {0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x03, 0xc0, 0x03, 0xc0, 0x03, + 0x80, 0x03, 0x80, 0x07, 0x90, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xf0, + 0x07, 0xf0, 0x00, 0x00, 0x0f, 0xf0, 0x0b, 0xb0, 0x00, 0x00}; + +const unsigned char ship4[] PROGMEM = {0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x03, 0xc0, 0x03, 0xc0, 0x03, + 0xc0, 0x01, 0xe0, 0x0d, 0xf0, 0x0d, 0xf0, 0x0d, 0xf0, 0x0d, 0xf0, + 0x0d, 0xf0, 0x0c, 0x00, 0x0f, 0xf0, 0x0d, 0xe0, 0x00, 0x00}; + +const unsigned char ship5[] PROGMEM = {0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x03, 0xc0, 0x03, 0xc0, 0x01, + 0xc0, 0x01, 0x60, 0x0b, 0x70, 0x0f, 0x70, 0x0f, 0x70, 0x0f, 0x70, + 0x0f, 0x70, 0x0f, 0x00, 0x0f, 0xf0, 0x06, 0xf0, 0x00, 0x00}; + +const unsigned char ship6[] PROGMEM = {0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x03, 0xc0, 0x03, 0xc0, 0x04, + 0xc0, 0x04, 0xc0, 0x0c, 0xd0, 0x0f, 0xd0, 0x0f, 0xd0, 0x0f, 0xd0, + 0x0f, 0xd0, 0x0f, 0xc0, 0x0f, 0xf0, 0x0b, 0x70, 0x00, 0x00}; + +const unsigned char ship7[] PROGMEM = {0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x03, 0xc0, 0x03, 0xc0, 0x02, + 0x40, 0x06, 0x60, 0x0e, 0x60, 0x0f, 0xe0, 0x0f, 0xe0, 0x0f, 0xe0, + 0x0f, 0xe0, 0x07, 0xe0, 0x0f, 0xf0, 0x0d, 0xb0, 0x00, 0x00}; + +const unsigned char ship8[] PROGMEM = {0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x03, 0xc0, 0x03, 0xc0, 0x02, + 0x40, 0x06, 0x60, 0x0e, 0x70, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, + 0x1f, 0xf8, 0x07, 0xe0, 0x0f, 0xf0, 0x0d, 0xb0, 0x00, 0x00}; + +const unsigned char ship9[] PROGMEM = {0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x03, 0xc0, 0x03, 0xc0, 0x02, + 0x40, 0x06, 0x60, 0x0e, 0x70, 0x1f, 0xf8, 0x3f, 0xfc, 0x3f, 0xfc, + 0x3f, 0xfc, 0x07, 0xe0, 0x0f, 0xf0, 0x0d, 0xb0, 0x00, 0x00}; + +// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 432) +const unsigned char *ships[9] = {ship1, ship2, ship3, ship4, ship5, ship6, ship7, ship8, ship9}; +#endif
\ No newline at end of file diff --git a/mp3player/arduino/error.h b/mp3player/arduino/error.h new file mode 100644 index 0000000..eb30a2f --- /dev/null +++ b/mp3player/arduino/error.h @@ -0,0 +1,29 @@ +#ifndef ERR_H +#define ERR_H + +#include "display/display.h" + +#define ERR_LIGHT 12 + +class Error { +public: + Error(String err) { + Serial.println("err: " + err); + OLED::clear(); + OLED::println("err: " + err); + OLED::flush(); + blink_err_light(); + }; + +private: + void blink_err_light() { + pinMode(ERR_LIGHT, OUTPUT); + while (true) { + digitalWrite(ERR_LIGHT, HIGH); + delay(100); + digitalWrite(ERR_LIGHT, LOW); + delay(100); + } + } +}; +#endif
\ No newline at end of file diff --git a/mp3player/arduino/player.h b/mp3player/arduino/player.h new file mode 100644 index 0000000..7ea9b6e --- /dev/null +++ b/mp3player/arduino/player.h @@ -0,0 +1,26 @@ +#ifndef PLAYER_H +#define PLAYER_H +#include "DFRobotDFPlayerMini.h" +#include "error.h" +#include <SoftwareSerial.h> + +namespace Player { +SoftwareSerial s(10, 11); // RX, TX +DFRobotDFPlayerMini p; + +void begin() { + Serial.println("Initializing DFPlayer"); + + s.begin(9600); + + if (!p.begin(s)) + Error err("init failed"); + + Serial.println("DFPlayer online."); + + p.volume(5); // Set volume value. From 0 to 30 + p.play(1); // Play the first mp3 + Serial.println(p.readFileCounts()); +} +} // namespace Player +#endif
\ No newline at end of file diff --git a/sizer/sizer.ino b/sizer/sizer.ino deleted file mode 100644 index b4a7221..0000000 --- a/sizer/sizer.ino +++ /dev/null @@ -1,29 +0,0 @@ -#define trigPin 13 -#define echoPin 12 -void setup() -{ - Serial.begin (9600); - pinMode(trigPin, OUTPUT); - pinMode(echoPin, INPUT); -} -void loop() -{ - long duration, distance; - digitalWrite(trigPin, LOW); - delayMicroseconds(2); - digitalWrite(trigPin, HIGH); - delayMicroseconds(10); - digitalWrite(trigPin, LOW); - duration = pulseIn(echoPin, HIGH); - distance = (duration/2) / 29.1; - if (distance >= 200 || distance <= 0) - { - Serial.println("Out of range"); - } - else - { - Serial.print(distance); - Serial.println(" cm"); - } - delay(500); -}
\ No newline at end of file |