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
99 Serial.println("setup start");
110 Serial.println("setup end");
122 int last_all_ok = -1;
129 static uint8_t counter = 0;
130 const int nlines = 6;
131 char line[nlines][256];
133 digitalWrite(8+7, led_beat);
134 led_beat = !led_beat;
143 if ( rtc_ok == 0 ) rtc_ok = rtc_read(line[0]);
145 Serial.println("RTC OK");
149 if ( edid_ok == 0 ) edid_ok = edid_read(line[1]);
150 if ( edid_ok == 1 ) {
151 Serial.println("EDID OK");
155 if ( adc_ok < 8 ) adc_ok = adc_read(line[2]);
157 Serial.println("ADC OK");
161 if ( dac_ok == 0 ) dac_ok = dac_read(line[3]);
163 Serial.println("DAC OK");
168 int btn = btn_read(line[4]); // buttons. DIP switches and blink LEDs
169 if ( btn_ok == 0 && btn == 7 ) {
170 Serial.println("BTN OK");
176 if(line[4][5] == '1') // BTN1 pressed
182 if(line[4][6] == '2') // BTN2 pressed - shutdown
184 volatile uint32_t *simple_out = (uint32_t *)0xFFFFFF10;
185 simple_out[0] |= (1<<13); // bit 13 of simple_out is shutdown
188 char flash_str[64], sd_str[64], oled_str[64];
189 if ( flash_ok == 0 ) flash_ok = flash_read(flash_str);
190 if ( flash_ok == 1 ) {
191 Serial.println("FLASH OK");
196 if ( sd_ok == 0 ) sd_ok = sd_read(sd_str); // esp32 must be flashed not to access SD card
198 Serial.println("SD OK");
207 Serial.print("all_ok=");
208 Serial.println(all_ok);
210 sprintf(line[5], "%s %s %s\n", flash_str, oled_str, sd_str);
212 //ram_test(line[5]); // works but too slow, need speedup
214 for(int i = 0; i < nlines; i++)
215 Serial.print(line[i]);
218 for(int i = 0; i < nlines; i++)
221 while((*c2.vblank_reg & 0x80) == 0);