-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSSD1306Emulator.ino
More file actions
70 lines (56 loc) · 1.57 KB
/
SSD1306Emulator.ino
File metadata and controls
70 lines (56 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* SSD1306Emulator - a simple emulator to render data intended for an SSD1306 to DVI using PicoDVI
* 2024-07-21 Lorandil
*/
#include "SimpleOLEDRenderer.h"
#include "VirtualSSD1306.h"
//#define DIAGNOSTIC_BOOT
// setup SSD1306 emulation layer
VirtualSSD1306 virtualSSD1306( 128, 64, true );
// declare global rendering class pointer
RendererBase *pRenderer{};
/*---------------------------------------------------------------------------*/
void setup()
{
pinMode( LED_BUILTIN, OUTPUT );
digitalWrite( LED_BUILTIN, true );
Serial.begin( 115200 );
#ifdef DIAGNOSTIC_BOOT
// give the Pico and the OS some time to establish a serial connection
for ( int n = 0; n < 2; n++ )
{
Serial.print( F(".") );
delay( 1000 );
}
Serial.println();
#else
// start virtual SSD1306 early
virtualSSD1306.begin( SSD1306_I2C_DEFAULT_ADDRESS );
#endif
// create a render class
pRenderer = new SimpleOLEDRenderer( &virtualSSD1306, 2, 2 );
// no overflow so far
digitalWrite( LED_BUILTIN, false );
// screen initilization
pRenderer->initScreen();
#ifdef DIAGNOSTIC_BOOT
// start virtual SSD1306 later, so that serial output will be visible
virtualSSD1306.begin( SSD1306_I2C_DEFAULT_ADDRESS );
#endif
}
/*---------------------------------------------------------------------------*/
void loop()
{
pRenderer->renderBackground();
uint32_t count{};
while ( true )
{
virtualSSD1306.processData();
// render the screen all 1000 cycles
if ( ( count++ % 1000 ) == 0 )
{
virtualSSD1306.performScrolling();
pRenderer->renderScreen();
}
}
}