From 076e22d69173ffbd28824e7a421934347b36bfec Mon Sep 17 00:00:00 2001 From: DashyFox Date: Thu, 21 Sep 2023 19:27:15 +0300 Subject: [PATCH] add display ^^ --- MusicRing.ino | 64 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/MusicRing.ino b/MusicRing.ino index 2e699ba..746dc33 100644 --- a/MusicRing.ino +++ b/MusicRing.ino @@ -1,4 +1,8 @@ +#include +#define SCREEN_WIDTH 128 // OLED display width, in pixels +#define SCREEN_HEIGHT 32 // OLED display height, in pixels +Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); #define pin_Data 5 // yellow #define pin_CLK_inside 6 // orange @@ -14,12 +18,54 @@ void shift(uint16_t, bool = true); uint8_t position = 1; void setup() { + Serial.begin(115200); + pinMode(pin_Data, OUTPUT); pinMode(pin_CLK_inside, OUTPUT); pinMode(pin_CLK_outside, OUTPUT); pinMode(pin_RESET, OUTPUT); pinMode(pin_OutputEnable, OUTPUT); + display.begin(SSD1306_SWITCHCAPVCC, 0x3C); + display.clearDisplay(); + // 'Text1', 128x32px + static const uint8_t DashyFox [] PROGMEM = { + 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, + 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, + 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0xc0, 0x07, 0xf0, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x80, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x07, 0xfc, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x80, 0x06, 0x1c, 0x0f, 0x60, 0xfc, 0x7f, 0x03, 0x9c, 0x30, 0x01, 0xe0, 0xc3, 0x00, 0x00, 0x01, + 0x80, 0x06, 0x0e, 0x1f, 0xe1, 0xfc, 0x7f, 0x87, 0xbc, 0x30, 0x07, 0xf0, 0xe7, 0x00, 0x00, 0x01, + 0x80, 0x06, 0x0e, 0x3f, 0xe1, 0xfc, 0x7f, 0xc7, 0xbc, 0x3f, 0x87, 0xf8, 0xe7, 0x00, 0x00, 0x01, + 0x80, 0x06, 0x0e, 0x30, 0xe3, 0x8c, 0x71, 0xc3, 0x0c, 0x3f, 0xce, 0x38, 0x7e, 0x00, 0x00, 0x01, + 0x80, 0x06, 0x0e, 0x70, 0xe1, 0xe0, 0x70, 0xc7, 0x0c, 0x3f, 0x8e, 0x18, 0x3c, 0x00, 0x00, 0x01, + 0x80, 0x06, 0x0e, 0x70, 0xe1, 0xf8, 0x70, 0xc7, 0x0c, 0x30, 0x0c, 0x18, 0x3c, 0x00, 0x00, 0x01, + 0x80, 0x06, 0x0e, 0x70, 0xe0, 0xfc, 0x70, 0xc7, 0x0c, 0x30, 0x0c, 0x18, 0x3c, 0x00, 0x00, 0x01, + 0x80, 0x06, 0x0c, 0x70, 0xe0, 0x1c, 0x70, 0xc7, 0x0c, 0x30, 0x0c, 0x18, 0x3c, 0x00, 0x00, 0x01, + 0x80, 0x06, 0x1c, 0x31, 0xe3, 0x8c, 0x71, 0xc3, 0x0c, 0x30, 0x0e, 0x38, 0x7e, 0x00, 0x00, 0x01, + 0x80, 0x07, 0xf8, 0x3f, 0xf3, 0xfc, 0x79, 0xe3, 0xfc, 0x30, 0x07, 0xf8, 0xe7, 0x00, 0x00, 0x01, + 0x80, 0x07, 0xf0, 0x1f, 0xf1, 0xfc, 0x79, 0xe1, 0xfc, 0x30, 0x07, 0xf0, 0xe7, 0x00, 0x00, 0x01, + 0x80, 0x07, 0xe0, 0x0f, 0x60, 0xf8, 0x71, 0xc1, 0xfc, 0x30, 0x01, 0xe0, 0xc3, 0x00, 0x00, 0x01, + 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x03, + 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xbc, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x03, + 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x07, + 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, + 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, + 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff + }; + display.drawBitmap(0, 0, DashyFox, 128, 32, WHITE); + display.display(); + digitalWrite(pin_RESET, HIGH); reset(); @@ -39,20 +85,34 @@ void setup() { uint8_t del = 42; digitalWrite(pin_Data, HIGH); shift(LED_count); - delay(del*1.5); + delay(del * 1.5); reset(); delay(del); } } void loop() { + + //105,23 + static uint32_t tmr; + static uint8_t arr [6] = { 0x3f>>1, 0xf0 ,0x7f>>3, 0xf8, 0x3f>>1, 0xf0 }; + static uint8_t arr2 [6]= { 0 }; + static bool f = false; + if (millis() - tmr > 350) { + display.drawBitmap(105, 23, arr, 16, 3, f); + display.display(); + tmr = millis(); + f = !f; + } + + if (position >= LED_count) { point_ini(1); position = 1; } else shift(1); - delay(1000/ 2 /LED_count); // Если больше 2х перейти на micros + delayMicroseconds(1000000 / 42 / LED_count); // Если больше 2х перейти на micros } void point_ini(uint8_t width) {