avr: work on simple GUI module to be used by node c02.
This commit is contained in:
@@ -268,6 +268,14 @@
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef MODULES_GUI
|
||||
.include "modules/lcd2/gui/defs.asm"
|
||||
.include "modules/lcd2/gui/main.asm"
|
||||
.include "modules/lcd2/gui/window.asm"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MODULES_FONT_8X8
|
||||
.include "modules/lcd2/font/defs.asm"
|
||||
.include "modules/lcd2/font/font8x8.asm"
|
||||
|
||||
@@ -179,6 +179,11 @@ onSystemTimerTick:
|
||||
bigcall Brightness_Every100ms
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_GUI
|
||||
bigcall GUI_Every100ms
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef APPS_NETWORK
|
||||
ldi yl, LOW(netInterfaceData)
|
||||
ldi yh, HIGH(netInterfaceData)
|
||||
@@ -196,7 +201,7 @@ onSystemTimerTick:
|
||||
#ifdef APPS_MA_LIGHT
|
||||
bigcall AppMotionLight_Every100ms
|
||||
#endif
|
||||
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
@@ -193,6 +193,10 @@ initModules:
|
||||
bigcall ILI9341_Init
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_GUI
|
||||
bigcall GUI_Init
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_BRIGHTNESS
|
||||
bigcall Brightness_Init
|
||||
#endif
|
||||
|
||||
@@ -137,8 +137,7 @@ main:
|
||||
.include "modules/flash/defs.asm"
|
||||
.include "modules/flash/eeprom.asm"
|
||||
.include "modules/flash/io.asm"
|
||||
.include "modules/flash/io_attn.asm"
|
||||
.include "modules/flash/io_bitbang.asm"
|
||||
.include "modules/flash/io_com2w.asm"
|
||||
.include "modules/flash/flash1pmega.asm"
|
||||
.include "modules/flash/flashxp.asm"
|
||||
.include "modules/flash/flashprocess.asm"
|
||||
|
||||
@@ -72,15 +72,15 @@
|
||||
.equ COM_DATA_OUTPUT = PORTD
|
||||
.equ COM_DATA_PIN = PORTD0
|
||||
|
||||
.equ COM_ATTN_DDR = DDRD
|
||||
.equ COM_ATTN_INPUT = PIND
|
||||
.equ COM_ATTN_OUTPUT = PORTD
|
||||
.equ COM_ATTN_PIN = PORTD2
|
||||
.equ COM_CLK_DDR = DDRD
|
||||
.equ COM_CLK_INPUT = PIND
|
||||
.equ COM_CLK_OUTPUT = PORTD
|
||||
.equ COM_CLK_PIN = PORTD2
|
||||
|
||||
.equ COM_IRQ_ADDR_ATTN = EIMSK
|
||||
.equ COM_IRQ_BIT_ATTN = INT0
|
||||
.equ COM_IRQ_GIFR_ATTN = INTF0
|
||||
;.equ COM_IRQ_GIMSK_ATTN = PCIE0
|
||||
.equ COM_IRQ_ADDR_CLK = EIMSK
|
||||
.equ COM_IRQ_BIT_CLK = INT0
|
||||
.equ COM_IRQ_GIFR_CLK = INTF0
|
||||
;.equ COM_IRQ_GIMSK_CLK = PCIE0
|
||||
|
||||
|
||||
|
||||
@@ -127,9 +127,12 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; ILI9341 module
|
||||
|
||||
.equ DISPLAY_WIDTH = 320
|
||||
.equ DISPLAY_HEIGHT = 240
|
||||
|
||||
.equ ILI9341_DEVICENUM = 0
|
||||
.equ ILI9341_DSP_WIDTH = 320
|
||||
.equ ILI9341_DSP_HEIGHT = 240
|
||||
.equ ILI9341_DSP_WIDTH = DISPLAY_WIDTH
|
||||
.equ ILI9341_DSP_HEIGHT = DISPLAY_HEIGHT
|
||||
|
||||
.equ ILI9341_RESET_DDR = DDRB
|
||||
.equ ILI9341_RESET_OUTPUT = PORTB
|
||||
|
||||
@@ -47,16 +47,17 @@
|
||||
; #define MODULES_TIMER
|
||||
#define MODULES_CLOCK
|
||||
;#define MODULES_XRAM
|
||||
#define MODULES_HEAP
|
||||
;#define MODULES_HEAP
|
||||
#define MODULES_LED_SIMPLE
|
||||
#define MODULES_NETWORK
|
||||
;#define MODULES_COMONUART0
|
||||
;#define MODULES_UART_HW
|
||||
#define MODULES_UART_BITBANG
|
||||
;#define MODULES_UART_BITBANG
|
||||
#define MODULES_COM2W
|
||||
#define MODULES_SPI_HW
|
||||
#define MODULES_ILI9341
|
||||
#define MODULES_FONT
|
||||
#define MODULES_WIN
|
||||
#define MODULES_GUI
|
||||
;#define MODULES_TWI_MASTER
|
||||
;#define MODULES_LCD
|
||||
;#define LCD_MINIMAL_FONT
|
||||
@@ -112,7 +113,7 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; Reset and interrupt vectors
|
||||
jmp BOOTLOADER_ADDR ; 1: Reset vector RESET
|
||||
jmp UART_BitBang_PcintIsr ; 2: INT0 External Interrupt Request 0
|
||||
jmp com2wPcintIsr ; 2: INT0 External Interrupt Request 0
|
||||
jmp irqNotSet ; 3: INT1 External Interrupt Request 1
|
||||
jmp irqNotSet ; 4: INT2 External Interrupt Request 2
|
||||
jmp irqNotSet ; 5: PCINT0 Pin Change Interrupt Request 0
|
||||
@@ -227,222 +228,110 @@ onEveryLoop:
|
||||
;.include "modules/lcd2/font/font16x26.asm"
|
||||
;.include "modules/lcd2/font/font4.asm"
|
||||
;.include "modules/lcd2/font/font12x16.asm"
|
||||
.include "modules/lcd2/font/font5.asm"
|
||||
.include "modules/lcd2/font/font12x20.asm"
|
||||
.include "modules/lcd2/ili9341/font6x8.asm"
|
||||
.include "modules/lcd2/ili9341/font6x8_1.asm"
|
||||
;.include "common/list_t.asm"
|
||||
.include "common/tree_t.asm"
|
||||
.include "common/divide.asm"
|
||||
;.include "common/tree_t.asm"
|
||||
;.include "common/divide.asm"
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; defines for network interface
|
||||
|
||||
;.equ netInterfaceData = netUartIface
|
||||
.equ netInterfaceData = uart_bitbang_iface
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; @param %0 X
|
||||
; @param %1 Y
|
||||
; @param %2 W
|
||||
; @param %3 H
|
||||
.macro M_FILL_RECT
|
||||
ldi r16, LOW(@0) ; X0
|
||||
mov r4, r16
|
||||
ldi r16, HIGH(@0)
|
||||
mov r5, r16
|
||||
|
||||
ldi r16, LOW(@1) ; Y0
|
||||
mov r6, r16
|
||||
ldi r16, HIGH(@1)
|
||||
mov r7, r16
|
||||
|
||||
ldi r16, LOW(@2) ; W
|
||||
mov r8, r16
|
||||
ldi r16, HIGH(@2)
|
||||
mov r9, r16
|
||||
|
||||
ldi r16, LOW(@3) ; H
|
||||
mov r10, r16
|
||||
ldi r16, HIGH(@3)
|
||||
mov r11, r16
|
||||
|
||||
bigcall ILI9341_FillRect
|
||||
.endmacro
|
||||
;.equ netInterfaceData = uart_bitbang_iface
|
||||
.equ netInterfaceData = com2w_iface
|
||||
|
||||
|
||||
|
||||
|
||||
test:
|
||||
; set foreground (r3:r2)
|
||||
; 0bRRRRRGGGGGGBBBBB
|
||||
ldi r16, 0b11111111
|
||||
mov r3, r16
|
||||
ldi r16, 0b11111111 ; white
|
||||
mov r2, r16
|
||||
M_FILL_RECT 0, 0, 319, 239
|
||||
|
||||
; set foreground (r3:r2)
|
||||
ldi r16, 0b00000000
|
||||
mov r3, r16
|
||||
ldi r16, 0b00011111 ; blue
|
||||
mov r2, r16
|
||||
M_FILL_RECT 0, 0, 319, 32
|
||||
|
||||
; set background (r1:r0)
|
||||
mov r0, r2
|
||||
mov r1, r3
|
||||
|
||||
; set foreground (r3:r2)
|
||||
ldi r16, 0b11111111
|
||||
mov r3, r16
|
||||
ldi r16, 0b11111111 ; white
|
||||
mov r2, r16
|
||||
|
||||
; set Xpos
|
||||
ldi r16, LOW(10)
|
||||
mov r4, r16
|
||||
ldi r16, HIGH(10)
|
||||
mov r5, r16
|
||||
|
||||
; setYpos
|
||||
ldi r16, LOW(3)
|
||||
mov r6, r16
|
||||
ldi r16, HIGH(3)
|
||||
mov r7, r16
|
||||
|
||||
; set font
|
||||
; ldi zl, LOW(font3_16x26*2)
|
||||
; ldi zh, HIGH(font3_16x26*2)
|
||||
ldi zl, LOW(font5_12x20*2)
|
||||
ldi zh, HIGH(font5_12x20*2)
|
||||
|
||||
; set buffer
|
||||
ldi xl, LOW(glyphBuffer)
|
||||
ldi xh, HIGH(glyphBuffer)
|
||||
|
||||
; write characters
|
||||
ldi r16, 'A'
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
|
||||
ldi r16, 'Q'
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
|
||||
ldi r16, 'H'
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
|
||||
ldi r16, 'O'
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
|
||||
ldi r16, 'M'
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
|
||||
ldi r16, 'E'
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
|
||||
#if 0
|
||||
push xl
|
||||
push xh
|
||||
rcall listTest1
|
||||
pop xh
|
||||
pop xl
|
||||
brcc test_error
|
||||
ldi r16, '!'
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
|
||||
push xl
|
||||
push xh
|
||||
rcall listTest2
|
||||
pop xh
|
||||
pop xl
|
||||
brcc test_error
|
||||
ldi r16, '!'
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
|
||||
push xl
|
||||
push xh
|
||||
rcall listTest3
|
||||
pop xh
|
||||
pop xl
|
||||
brcc test_error
|
||||
ldi r16, '!'
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
|
||||
push xl
|
||||
push xh
|
||||
rcall listTest4
|
||||
pop xh
|
||||
pop xl
|
||||
brcc test_error
|
||||
ldi r16, '!'
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
#endif
|
||||
|
||||
#ifdef MODULES_GUI
|
||||
ldi yl, LOW(mainWindow)
|
||||
ldi yh, HIGH(mainWindow)
|
||||
ldi zl, LOW(mainWindowInFlash*2);
|
||||
ldi zh, HIGH(mainWindowInFlash*2);
|
||||
ldi r17, WIN_SIZE
|
||||
testCopyWinLoop:
|
||||
lpm r16, Z+
|
||||
st Y+, r16
|
||||
dec r17
|
||||
brne testCopyWinLoop
|
||||
|
||||
ldi yl, LOW(mainWindow)
|
||||
ldi yh, HIGH(mainWindow)
|
||||
bigcall Window_Clear
|
||||
#if 1
|
||||
push xl
|
||||
push xh
|
||||
rcall treeTest1
|
||||
pop xh
|
||||
pop xl
|
||||
brcc test_error
|
||||
ldi r16, '!'
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
ldi zl, LOW(mainWindowTitle*2)
|
||||
ldi zh, HIGH(mainWindowTitle*2)
|
||||
; print title at 10/2
|
||||
ldi r16, 10
|
||||
mov r4, r16
|
||||
clr r5
|
||||
ldi r16, 2
|
||||
mov r6, r16
|
||||
clr r7
|
||||
bigcall Window_DrawTextFlash
|
||||
#else
|
||||
ldi zl, LOW(ili9341Font6x8_1*2)
|
||||
ldi zh, HIGH(ili9341Font6x8_1*2)
|
||||
|
||||
push xl
|
||||
push xh
|
||||
rcall treeTest2
|
||||
pop xh
|
||||
pop xl
|
||||
brcc test_error
|
||||
ldi r16, '!'
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
ldi r16, LOW(0b0000000000000000)
|
||||
mov r0, r16
|
||||
ldi r16, HIGH(0b0000000000000000)
|
||||
mov r1, r16
|
||||
|
||||
push xl
|
||||
push xh
|
||||
rcall treeTest3
|
||||
pop xh
|
||||
pop xl
|
||||
brcc test_error
|
||||
ldi r16, '!'
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
ldi r16, LOW(0b1111111111111111)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(0b1111111111111111)
|
||||
mov r3, r16
|
||||
|
||||
push xl
|
||||
push xh
|
||||
rcall treeTest4
|
||||
pop xh
|
||||
pop xl
|
||||
brcc test_error
|
||||
ldi r16, '!'
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
ldi r16, 10
|
||||
mov r4, r16
|
||||
clr r5
|
||||
ldi r16, 20
|
||||
mov r6, r16
|
||||
clr r7
|
||||
|
||||
ldi r16, 'A'
|
||||
bigcall Display_DrawChar
|
||||
|
||||
add r4, r18
|
||||
adc r5, r19
|
||||
|
||||
ldi r16, 'B'
|
||||
bigcall Display_DrawChar
|
||||
|
||||
#endif
|
||||
|
||||
ret
|
||||
|
||||
test_error:
|
||||
ldi r17, '0'
|
||||
add r16, r17
|
||||
bigcall ili9341_WriteCharacterX1At
|
||||
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
helloWorld: .db "Hello World", 0
|
||||
testHandler:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
#ifdef MODULES_GUI
|
||||
mainWindowInFlash:
|
||||
.dw testHandler ; handler
|
||||
.dw 0 ; X
|
||||
.dw 0 ; Y
|
||||
.dw DISPLAY_WIDTH
|
||||
.dw DISPLAY_HEIGHT
|
||||
; 0bRRRRRGGGGGGBBBBB
|
||||
.dw 0b0000000000011111 ; blue
|
||||
; .dw 0b1111100000000000 ; red
|
||||
.dw 0b1111111111111111 ; white
|
||||
.dw (ili9341Font6x8_1*2)
|
||||
|
||||
mainWindowTitle: .db "AQHOME", 0, 0
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
.dseg
|
||||
|
||||
glyphBuffer: .byte 1024
|
||||
mainWindow: .byte WIN_SIZE
|
||||
|
||||
heapStart:
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user