1 #include <Compositing.h>
15 #define N_LETTERS (sizeof(Font)/sizeof(Font[0]))
21 int Cursor_col = 0, Cursor_row = 0;
25 for(int row = 0; row < Rows; row++)
26 for(int col = 0; col < Cols; col++)
28 int i = N_LETTERS + row*Cols + col;
29 c2.sprite_link_content('@'-'@', i);
31 Cursor_col = Cursor_row = 0;
38 int i = N_LETTERS + Cursor_row*Cols + Cursor_col;
39 uint8_t letter = 0; // space is default
44 Cursor_row = (Cursor_row + 1) % Rows;
48 if(c >= ' ' && c <= '_')
50 c2.sprite_link_content(letter, i);
51 if(++Cursor_col >= Cols)
54 Cursor_row = (Cursor_row + 1) % Rows;
59 // initialize compositing2 text using sprites
65 c2.alloc_sprites(N_LETTERS+Rows*Cols); // it sets c2.sprite_max
66 *c2.videobase_reg = NULL; // disable video during update
69 for(i = 0; i < c2.sprite_max && i < N_LETTERS; i++)
70 c2.shape_to_sprite(&(Font[i]));
71 unique_sprites = c2.n_sprites;
72 // unique sprites containing alphabet are not displayed, set them off-screen
73 for(i = 0; i < unique_sprites; i++)
75 c2.Sprite[i]->x = -100;
76 c2.Sprite[i]->y = -100;
78 // position cloned sprites on display
80 for(int row = 0; row < Rows; row++)
81 for(int col = 0; col < Cols; col++)
83 c2.sprite_clone(0); // by default clone 0-sprite which is space
84 int n = N_LETTERS + row*Cols + col;
85 c2.Sprite[n]->x = col*16;
86 c2.Sprite[n]->y = row*16;
92 // this is needed for vgatext
93 // to disable textmode and enable bitmap
94 *c2.cntrl_reg = 0b11000000; // enable video, yes bitmap, no text mode, no cursor
111 static uint8_t counter = 0;
112 const int nlines = 6;
113 char line[nlines][256];
122 btn_read(line[4]); // buttons. DIP switches and blink LEDs
123 if(line[4][5] == '1') // BTN1 pressed
129 if(line[4][6] == '2') // BTN2 pressed - shutdown
131 volatile uint32_t *simple_out = (uint32_t *)0xFFFFFF10;
132 simple_out[0] |= (1<<13); // bit 13 of simple_out is shutdown
134 char flash_str[64], sd_str[64], oled_str[64];
135 flash_read(flash_str);
136 sd_read(sd_str); // esp32 must be flashed not to access SD card
138 sprintf(line[5], "%s %s %s\n", flash_str, oled_str, sd_str);
140 //ram_test(line[5]); // works but too slow, need speedup
142 for(int i = 0; i < nlines; i++)
143 Serial.print(line[i]);
145 for(int i = 0; i < nlines; i++)
147 while((*c2.vblank_reg & 0x80) == 0);