Jared DiCarlo
/
manworm_tv_gpu
asdf
Fork of manworm_ticker_tv by
Diff: main.cpp
- Revision:
- 12:e99cc1e9d928
- Parent:
- 11:537cde55b27f
--- a/main.cpp Thu May 03 23:38:46 2018 +0000 +++ b/main.cpp Fri May 04 01:45:05 2018 +0000 @@ -3,11 +3,15 @@ #include "lisp.h" #include "main.h" #include "gfx.h" +#include "face.h" // Resolution, including porches #define V_RES 200 #define H_RES 300 +#define TEXT_LEVEL 5 + + // old shit #define SX_MIN 30 @@ -35,15 +39,21 @@ #define N_COLOR 16 +// DAC stuff +#define DAC_SYNC 2 + uint8_t char_col = 0; // current column counter uint8_t char_row = 0; // current row counter uint8_t text_buffer_counter = 0; // current index in text buffer counter char most_recent_char = '0'; +uint8_t line_intensity = 0; +int8_t line_dir = 1; + char text_buffer[TX*TY]; // input text buffer for lisp -AnalogIn joy1(A0); -AnalogIn joy2(A1); +AnalogIn joy1(A1); +AnalogIn joy2(A0); uint8_t want_gfx = 0; uint8_t vsync = 0; @@ -185,6 +195,11 @@ DigitalOut sout(D8); //sync PA_9 DigitalOut vout(D7); //video PA_8 +DigitalOut dac0(PA_4); +DigitalOut dac1(PA_5); +DigitalOut dac2(PA_6); +DigitalOut dac3(PA_7); + // trigger horizontal line draw Ticker t; @@ -259,8 +274,8 @@ clr(); // zero buffers for(int i = 0; i < H_RES; i++) { - im_line_s[i] = 1; - bl_line_s[i] = 1; + im_line_s[i] = DAC_SYNC; + bl_line_s[i] = DAC_SYNC; bl_line_v[i] = 0; vb_line_s[i] = 0; vb_line_v[i] = 0; @@ -275,14 +290,14 @@ bl_line_s[0] = 0; - vb_line_s[0] = 1; + vb_line_s[0] = DAC_SYNC; bl_line_s[1] = 0; - vb_line_s[1] = 1; + vb_line_s[1] = DAC_SYNC; bl_line_s[3] = 0; - vb_line_s[3] = 1; + vb_line_s[3] = DAC_SYNC; bl_line_s[2] = 0; - vb_line_s[2] = 1; + vb_line_s[2] = DAC_SYNC; } // video interrupt @@ -298,20 +313,21 @@ for(uint16_t i = 0; i < lmax; i++) //loop over each column { nop = 1; - if(sptr[i]) - GPIOA->ODR |= (1 << 9); - else - GPIOA->ODR &= ~(1 << 9); - - if(vptr[i]) - GPIOA->ODR |= (1 << 8); - else - GPIOA->ODR &= ~(1 << 8); + GPIOA->ODR = (vptr[i] + sptr[i]) << 4; +// if(sptr[i]) +// GPIOA->ODR |= (1 << 9); +// else +// GPIOA->ODR &= ~(1 << 9); +// +// if(vptr[i]) +// GPIOA->ODR |= (1 << 8); +// else +// GPIOA->ODR &= ~(1 << 8); if(nop) //nop delay { - asm("nop");asm("nop");//asm("nop");asm("nop");//asm("nop");asm("nop");asm("nop");//asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop"); + asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");//asm("nop");asm("nop");asm("nop");asm("nop"); } else {wait_us(1); if(i > 2) i+=1;} //wait delay } @@ -355,14 +371,14 @@ void draw_vert(int16_t y0, int16_t y1, int16_t x0) { for(int16_t i = y0; i < y1; i++) - im_line_va[H_RES*i + x0] = 1; + im_line_va[H_RES*i + x0] = line_intensity; } // draw horizonal line void draw_horiz(int16_t x0, int16_t x1, int16_t y0) { for(int16_t i = x0; i < x1; i++) - im_line_va[H_RES*y0 + i] = 1; + im_line_va[H_RES*y0 + i] = line_intensity; } // draw line between points @@ -379,12 +395,12 @@ for(int16_t x = x0; x < x1; x++) { //plotxy - im_line_va[H_RES*y + x] = !draw_line_inv; + im_line_va[H_RES*y + x] = (!draw_line_inv)?line_intensity:0; err += derr; while(err >= 0.5f) { y += sign(dy); - im_line_va[H_RES*y + x] = !draw_line_inv; + im_line_va[H_RES*y + x] = (!draw_line_inv)?line_intensity:0; err -= 1.f; } } @@ -400,7 +416,7 @@ { for(uint16_t yp = 0; yp < 8; yp++) { - im_line_va[H_RES*(yp+y0) + xp + x0] = CHECK_BIT(letter[yp],8-xp); + im_line_va[H_RES*(yp+y0) + xp + x0] = CHECK_BIT(letter[yp],8-xp)?TEXT_LEVEL:0; } } } @@ -616,6 +632,17 @@ //} int main() { +// int n = 0; +// pc.baud(115200); +// for(;;) +// { +// +// n++; +// n = n%16; +// GPIOA->ODR = (n<<4); +// pc.printf("val: 0x%hhx\r\n",(n<<4)); +// +// } im_line_va = im_line_va_1; // init serial pc.baud(115200); @@ -669,8 +696,10 @@ // main loop want_gfx = 1; + int num_iters; for(;;) { + if(want_lisp) { new_line(); @@ -693,6 +722,35 @@ clr(); float j2 = joy1.read() - .5f;; float j1 = joy2.read() - .5f; + + num_iters++; + + if( (num_iters % 5) == 0) + { + if(line_dir == 1) + { + line_intensity++; + if(line_intensity >= 8) + line_dir = -1; + } + else + { + line_intensity--; + if(line_intensity == 0) + line_dir = 1; + } + } + + + for(int x = 0; x < XL-0; x++) + { + for(int y = 0; y < YL-0; y++) + { + im_line_va[H_RES*(y+Y0) + x + X0] = splash[YL - y][x] >> 4; + //im_line_va[H_RES*y + x] = (y/6)%10; + // im_line_va[H_RES*y + x] = ( (x-X0) + (y-Y0) )/24 - 2; + } + } new_frame(j1,j2); draw_line(X0, Y0, X0 + XL, Y0); draw_line(X0+XL,Y0,X0+XL,Y0+YL); @@ -716,8 +774,16 @@ //draw_gfx_line(-0.01,-0.01,0.01,0.01); char joy_string[20]; sprintf(joy_string,"1: %.2f 2: %.2f",joy1.read(),joy2.read()); - //set_status_string(joy_string); - set_status_string(get_gfx_stat()); + set_status_string(joy_string); + + + //im_line_va[H_RES*y0 + i] = 1; + +// #define X0 75 // start of image in X +//#define Y0 30 // start of image in Y +//#define XL 220 // 25 chars +//#define YL 165 // 20 chars + //set_status_string(get_gfx_stat()); vsync = 0; //swap_buffers();