diff --git a/.DS_Store b/.DS_Store index 1786a19..9ab5787 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 1e60353..3ffb42e 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -3,7 +3,8 @@ { "name": "Mac", "includePath": [ - "/Users/gsd/Library/Arduino15/packages/**" + "/Users/gsd/Library/Arduino15/packages/**", + "/Users/gsd/Documents/Arduino/libraries/**" ], "defines": [], "compilerPath": "/usr/bin/clang", diff --git a/.vscode/settings.json b/.vscode/settings.json index 825d1c2..881bed7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,6 +11,15 @@ "unordered_map": "cpp", "vector": "cpp", "ostream": "cpp", - "map": "cpp" + "map": "cpp", + "__tree": "cpp", + "deque": "cpp", + "list": "cpp", + "regex": "cpp", + "set": "cpp", + "span": "cpp", + "unordered_set": "cpp", + "format": "cpp", + "text_encoding": "cpp" } } \ No newline at end of file diff --git a/pipboy-setup.sh b/pipboy-setup.sh index bbb63ed..ee16830 100644 --- a/pipboy-setup.sh +++ b/pipboy-setup.sh @@ -67,7 +67,7 @@ xset -dpms xset s noblank # Запуск Chromium -exec chromium-browser --no-memcheck --noerrdialogs --disable-infobars --disable-background-timer-throttling --disable-renderer-backgrounding --disable-backgrounding-occluded-windows --check-for-update-interval=31536000 --no-first-run --kiosk http://127.0.0.1 +exec chromium-browser --no-memcheck --noerrdialogs --disable-infobars --disable-background-timer-throttling --disable-renderer-backgrounding --disable-backgrounding-occluded-windows --check-for-update-interval=31536000 --no-first-run --incognito --kiosk http://127.0.0.1 EOT #uart diff --git a/pipboyIO/display.cpp b/pipboyIO/display.cpp new file mode 100644 index 0000000..7a554a3 --- /dev/null +++ b/pipboyIO/display.cpp @@ -0,0 +1,75 @@ +#include +#include +#include +#include + +//Adafruit_SSD1306 display1(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); +Adafruit_SSD1306 display2(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, -1); + +void initDisplay() { + /*Wire.begin(D1_I2C_SDA, D1_I2C_SCL); + if(!display1.begin(SSD1306_EXTERNALVCC, DISPLAY_I2C_ADDRESS)) { + Serial.println("SSD1306 #1 allocation failed"); + for(;;); + }*/ + + Wire1.begin(D2_I2C_SDA, D2_I2C_SCL); + if(!display2.begin(SSD1306_SWITCHCAPVCC, DISPLAY_I2C_ADDRESS)) { + Serial.println("SSD1306 #2 allocation failed"); + for(;;); + } + + //display1.clearDisplay(); + //Serial.println("start display 2"); + display2.clearDisplay(); + for (int x = 0; x < 128; x ++) { + for (int y = 0; y < 64; y++) { + display2.drawPixel(x, y, SSD1306_WHITE); + } + } + display2.display(); + //Serial.println("start display 2 test success"); +} + +void drawPoint(int displayId, int x, int y) { + switch (displayId) + { + case 1: + + //display1.clearDisplay(); + //display1.drawPixel(x, y, SSD1306_WHITE); + break; + case 2: + display2.clearDisplay(); + display2Border(); + display2.drawPixel(x, y, SSD1306_WHITE); + display2.display(); + break; + default: + break; + } +} + +const int16_t borders[][2] = { + {20, 59}, + {20, 30}, + {29, 15}, + {40, 3}, + {45, 1}, + {65, 0}, + {80, 1}, + {91, 3}, + {103, 15}, + {110, 30}, + {110, 59} + }; +const int borderSize = sizeof(borders) / sizeof(borders[0]); + +void display2Border() { + int x = 0; + int y = 1; + for (int i = 1; i + +#define DISPLAY_I2C_ADDRESS 0x3C +#define SCREEN_WIDTH 128 +#define SCREEN_HEIGHT 64 + +#define D1_I2C_SDA 21 +#define D1_I2C_SCL 5 + +#define D2_I2C_SDA 19 //19 +#define D2_I2C_SCL 18 //18 + +//Adafruit_SSD1306 display1(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); +//Adafruit_SSD1306 display2(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, -1); + +void initDisplay(); +void drawPoint(int displayId, int x, int y); +void display2Border(); \ No newline at end of file diff --git a/pipboyIO/pipboyIO.ino b/pipboyIO/pipboyIO.ino index f80517a..bba03cb 100644 --- a/pipboyIO/pipboyIO.ino +++ b/pipboyIO/pipboyIO.ino @@ -2,6 +2,7 @@ #include #include #include +#include "display.h" const int input[] = {}; long inputCurrentValue[] = {0, 0, 0, 0, 0, 0, 0, 0}; @@ -12,10 +13,12 @@ const int buttonInput[2] = {36,39}; int buttonLastState[2] = {HIGH, HIGH}; int buttonCurrentState[2]; +String inputBuffer = ""; + #define RXD2 (16) #define TXD2 (17) -//#define DEBUGIO +#define DEBUGIO void setup() { #ifdef DEBUGIO @@ -25,6 +28,7 @@ void setup() { #endif setupEncoder(); + initDisplay(); pinMode(buttonInput[0], INPUT); @@ -84,6 +88,37 @@ void loop() { setOldencoderCount(enc, getEncoderCount(enc)); } } + + //читаем кал + while (Serial.available() > 0) { + char chr = Serial.read(); + if (chr == '\n') { + processInput(inputBuffer); + inputBuffer = ""; + } else { + inputBuffer += chr; + } + } delay(50); } + +void processInput(String input) { + input.trim(); + + int firstSpace = input.indexOf(' '); + int secondSpace = input.indexOf(' ', firstSpace + 1); + + if (firstSpace == -1 || secondSpace == -1) { + return; + } + + String n1 = input.substring(0, firstSpace); + String n2 = input.substring(firstSpace + 1, secondSpace); + String n3 = input.substring(secondSpace + 1); + + int displayId = n1.toInt(); + int x = n2.toInt(); + int y = n3.toInt(); + drawPoint(displayId, x, y); +} \ No newline at end of file