;display repetitive wave forms on ILI9341 display with vectors
#chip mega328p,16
#option explicit
#include <glcd.h>
;
#define GLCD_TYPE GLCD_TYPE_ILI9341
'Pin mappings for SPI - this GLCD driver supports Hardware SPI and Software SPI
#define GLCD_DC portd.2 ; DIGITAL_2 ' Data command line DC
#define GLCD_CS portd.7 ; DIGITAL_7 ' Chip select line CS
#define GLCD_RESET portd.4 ; DIGITAL_4 ' Reset line Tie high..not needed but don't erase
#define GLCD_DO portb.0 ; DIGITAL_8 ' Data out | MOSI SDI
#define GLCD_SCK portb.4 ; DIGITAL_11 ' Clock Line SCK
; #define ILI9341_HardwareSPI ' remove/comment out if you want to use software SPI.
'GLCD selected extension font set. ASCII characters 31-254, the extended font uses 1358 bytes of program memory
#define GLCD_EXTENDEDFONTSET1
GLCDfntDefaultsize = 1
'GLCDCLS supports GLCDBackground as default
'GLCDCLS also support passing color parameter.
'GLCDCLS [color]
;
dir portc.0 in
dim volt as word
dim volt2 as word
dim ptr1 as word
dim ptr2 as word
dim buffer1 (80)
dim buffer2 (80)
dim xpos_new as word
dim ypos_new as byte
dim xpos_old as word
dim ypos_old as byte
dim xpos1_new as word
dim ypos1_new as byte
dim xpos1_old as word
dim ypos1_old as byte
;
GLCDRotate ( Portrait_Rev )
GLCDfntDefaultsize = 3
GLCDCLS ILI9341_BLUE
filledbox 0,0,239,257,ILI9341_BLACK
box 0,0,239,257,ILI9341_YELLOW
;
for ptr1=1 to 80 ;read 80 samples
volt = READAD10 (an0)
buffer1 (ptr1)=255-(volt/4) ;fit 1024 to screen 0,0
buffer2 (ptr1)=buffer1 (ptr1)
next ptr1
;
do ; start of main loop
ptr1=1
ptr2=1
do until ptr1=59 ;erase old screen data and redraw new
ypos_old=buffer2 (ptr1) ;old data
ypos_new=buffer2 (ptr1+1)
xpos_new=ptr2+4
;
ypos1_old=buffer1 (ptr1) ;new data
ypos1_new=buffer1 (ptr1+1)
xpos1_new=ptr2+4
;
line ptr2,ypos_old+1,xpos_new,ypos_new+1,ILI9341_BLACK ;erase last data
line ptr2,ypos1_old+1,xpos1_new,ypos1_new+1,ILI9341_cyan ;draw new data
;
ptr1=ptr1+1 ;data pointer
ptr2=ptr2+4 ;x position for start and end line x positions
loop
;ploting done now redraw cursor
line 1,127,239,127,ILI9341_GREEN ; Draw cursor
line 119,1,119,254,ILI9341_GREEN ;after ploting
;
do
volt = READAD10 (an0)
volt2 = READAD10 (an0)
loop until (volt>510) and (volt2>volt)
;
for ptr1=1 to 79 ;get new samples
volt = READAD10 (an0)
repeat 2 ;scale 1024 bit sample to 255 pixels ie divide by 4
set c off
rotate volt right
End Repeat
buffer2 (ptr1)=buffer1 (ptr1) ;new data to old data
buffer1 (ptr1)=255-volt ;set 0,0 top left screen and update new data
next ptr1
;
loop ;end of main