2024-12-29 15:05:40 -07:00
|
|
|
#include "pico/stdlib.h"
|
|
|
|
|
#include "pico/multicore.h"
|
2025-01-02 18:57:22 -07:00
|
|
|
#include "pico/mutex.h"
|
2024-12-29 15:05:40 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#include "fonts.h"
|
|
|
|
|
#include "deviceLegacy.h"
|
|
|
|
|
#include "deviceRTC.h"
|
|
|
|
|
#include "deviceEEPROM.h"
|
|
|
|
|
#include "deviceTouch.h"
|
|
|
|
|
#include "pixelDisplayDriver.h"
|
|
|
|
|
#include "pixelDisplayGC9A01A.h"
|
|
|
|
|
#include "pixelDisplayILI9341.h"
|
|
|
|
|
#include "pixelDisplaySH1106.h"
|
|
|
|
|
#include "pixelDisplaySH1122.h"
|
|
|
|
|
#include "pixelDisplayST7789.h"
|
|
|
|
|
#include "pixelDisplaySSD1306.h"
|
|
|
|
|
#include "pixelDisplaySSD1309.h"
|
|
|
|
|
#include "textDisplayDriver.h"
|
|
|
|
|
#include "textDisplayUS2066.h"
|
|
|
|
|
#include "color.h"
|
|
|
|
|
|
|
|
|
|
static deviceLegacy* device = NULL;
|
|
|
|
|
static bool refresh = false;
|
2025-01-02 18:57:22 -07:00
|
|
|
static mutex_t mutex;
|
2024-12-29 15:05:40 -07:00
|
|
|
|
|
|
|
|
void render_loop()
|
|
|
|
|
{
|
|
|
|
|
const uint16_t width = 128;
|
|
|
|
|
const uint16_t height = 64;
|
|
|
|
|
const uint16_t xShift = 0;
|
|
|
|
|
const uint16_t yShift = 0;
|
|
|
|
|
const uint16_t bitsPerPixel = 1;
|
|
|
|
|
|
2025-01-02 18:57:22 -07:00
|
|
|
spi_inst_t* spi = spi1;
|
2024-12-29 15:05:40 -07:00
|
|
|
const uint32_t baudRate = 100 * 1000;
|
2025-01-02 18:57:22 -07:00
|
|
|
const uint8_t txPin = 11;
|
2024-12-29 15:05:40 -07:00
|
|
|
const uint8_t sckPin = 10;
|
|
|
|
|
const uint8_t csnPin = 9;
|
|
|
|
|
const uint8_t rstPin = 12;
|
|
|
|
|
const uint8_t dcPin = 8;
|
|
|
|
|
const uint8_t backlightPin = 20;
|
|
|
|
|
|
|
|
|
|
pixelDisplaySSD1309* display = new pixelDisplaySSD1309(width, height, xShift, yShift, bitsPerPixel);
|
2025-01-02 18:57:22 -07:00
|
|
|
display->initSpi(spi, baudRate, txPin, sckPin, csnPin, rstPin, dcPin, backlightPin);
|
2024-12-29 15:05:40 -07:00
|
|
|
display->fill(0x000000);
|
|
|
|
|
display->drawDisplay();
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
2025-01-02 18:57:22 -07:00
|
|
|
if (refresh == true)
|
2024-12-29 15:05:40 -07:00
|
|
|
{
|
2025-01-02 18:57:22 -07:00
|
|
|
//mutex_enter_blocking(&mutex);
|
|
|
|
|
refresh = false;
|
|
|
|
|
//mutex_exit(&mutex);
|
|
|
|
|
|
2024-12-29 15:05:40 -07:00
|
|
|
display->fill(0x000000);
|
|
|
|
|
for (int y = 0; y < device->getRows(); y++)
|
|
|
|
|
{
|
|
|
|
|
for (int x = 0; x < device->getCols(); x++)
|
|
|
|
|
{
|
|
|
|
|
display->drawChar(0xffffff, fonts::Font_6x8(), (x * 6) + 2, y << 3, device->getDisplayChar(y, x));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
display->drawDisplay();
|
|
|
|
|
}
|
|
|
|
|
sleep_ms(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
stdio_init_all();
|
|
|
|
|
|
2025-01-02 18:57:22 -07:00
|
|
|
mutex_init(&mutex);
|
|
|
|
|
|
2024-12-29 15:05:40 -07:00
|
|
|
spi_inst_t* spi = spi0;
|
|
|
|
|
const uint32_t baudRate = 100 * 1000;
|
|
|
|
|
const uint8_t rxPin = 0;
|
|
|
|
|
const uint8_t csnPin = 1;
|
|
|
|
|
const uint8_t sckPin = 2;
|
|
|
|
|
|
|
|
|
|
device = new deviceLegacy(4, 20);
|
|
|
|
|
device->initSpi(spi, baudRate, rxPin, sckPin, csnPin);
|
|
|
|
|
multicore_launch_core1(render_loop);
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
bool needRefresh = device->poll();
|
|
|
|
|
if (needRefresh == true)
|
|
|
|
|
{
|
2025-01-02 18:57:22 -07:00
|
|
|
//mutex_enter_blocking(&mutex);
|
2024-12-29 15:05:40 -07:00
|
|
|
refresh = true;
|
2025-01-02 18:57:22 -07:00
|
|
|
//mutex_exit(&mutex);
|
2024-12-29 15:05:40 -07:00
|
|
|
}
|
|
|
|
|
sleep_ms(1);
|
|
|
|
|
}
|
|
|
|
|
}
|