asdf

Dependencies:   mbed

Fork of manworm_ticker_tv by Bayley Wang

Revision:
10:1163fb31b0a7
Parent:
9:2a47b9ff8911
Child:
11:537cde55b27f
--- a/main.cpp	Sat Mar 10 05:09:55 2018 +0000
+++ b/main.cpp	Sat Mar 10 06:26:01 2018 +0000
@@ -41,6 +41,7 @@
 char text_buffer[TX*TY]; // input text buffer for lisp
 
 uint8_t want_gfx = 0;
+uint8_t vsync = 0;
 
 Serial pc(USBTX, USBRX);
 
@@ -285,9 +286,9 @@
     uint8_t nop = 0; //use nops or use wait_us
     uint8_t* sptr; //pointer to sync buffer for line
     uint8_t* vptr; //pointer to video buffer for line
-    if(l < V_RES){ vptr = im_line_va + ((l)*H_RES); sptr = im_line_s; nop = 1; } //pick line buffers
-    else if(l < 254){ vptr = bl_line_v; sptr = bl_line_s; nop = 0; }
-    else{ vptr = vb_line_v; sptr = vb_line_s; nop = 1;}
+    if(l < V_RES){ vptr = im_line_va + ((l)*H_RES); sptr = im_line_s; nop = 1; vsync = 0;} //pick line buffers
+    else if(l < 254){ vptr = bl_line_v; sptr = bl_line_s; nop = 0;  }
+    else{ vptr = vb_line_v; sptr = vb_line_s; nop = 1; }
     uint16_t lmax = nop?H_RES:12; //number of columns
     for(uint16_t i = 0; i < lmax; i++) //loop over each column
     {
@@ -311,6 +312,7 @@
     }
     //move to next line
     l++;
+    if(l == V_RES) vsync = 1;
     if(l > 255) l = 0;
 }
 
@@ -660,37 +662,42 @@
     new_line();
     draw_vincent_string(">");
     // main loop
+    want_gfx = 1;
     for(;;) 
     {
         if(want_lisp) 
         {
             new_line();
             // runs interpreter and prints answer
-//            run_lisp(text_buffer);
-//            want_lisp = 0;
-//            new_line();
-//            clr_text_buff();
+            run_lisp(text_buffer);
+            want_lisp = 0;
+            new_line();
+            clr_text_buff();
             //draw_vincent_string(">");
         }
         
         if(want_gfx)
         {
+            if(!vsync) continue;
             if(!gfx_is_init)
             {
                 init_gfx();
                 gfx_is_init = 1;
             }   
+            clr();
             new_frame(most_recent_char);
-            most_recent_char = '0';
-            spin_for_a_while(100);
-            clr();
             draw_line(X0, Y0, X0 + XL, Y0);
             draw_line(X0+XL,Y0,X0+XL,Y0+YL);
             draw_line(X0, Y0+YL, X0 +XL, Y0+YL);
             draw_line(X0,Y0,X0,Y0+YL);
+            most_recent_char = '0';
+            //spin_for_a_while(400);
+            
+
             //draw_gfx_line(-0.01,-0.01,0.01,0.01);
 
             set_status_string(get_gfx_stat());
+            vsync = 0;
             //swap_buffers();
             
         }