annotate lcd.c @ 50:d7207a9d3c3b

Add write support. LFN still broken though. Make sure we wait for the card to be done after a read or write (didn't seem to break reading but hosed writes).
author Daniel O'Connor <darius@dons.net.au>
date Fri, 05 Apr 2013 00:08:31 +1030
parents be0a1ac64d97
children bb52e6dad784
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
1 /*
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
2 * Example code (I think)
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
3 * ~/projects/STM32Strive/奋斗STM32开发板例程/奋斗STM32开发板例程/奋斗STM32开发板MINI/STM32奋斗版ucOS II V2.86 uCGUI 3.9 DEMO-V2/STM32奋斗版ucOS II V2.86 uCGUI 3.9 DEMO
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
4 *
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
5 * Schematics
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
6 * Main board docs/Strive\ Mini\ STM32\ Schematic.pdf
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
7 * LCD board docs/Strive Mini LCD STM32 Schematic.pdf
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
8 * MCU reference manual docs/CD00171190.pdf
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
9 * MCU Data sheet (pinout) docs/CD00191185.pdf
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
10 * LCD controller data sheet docs/ili9325-v0.35.pdf
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
11 * LCD controller app notes docs/ILI9325AN_V0.22.pdf
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
12 * XXX: not sure what panel is connected
3
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
13 *
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
14 */
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
15 /* LCD board MCU
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
16 1 VCC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
17 2 TC_SCK PA5/SPI1_SCK
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
18 3 GND
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
19 4 TC_CS PB7/SPI1_CS3
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
20 5 RST PE1 FSMC_NBL1? (unlikely)
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
21 6 TC_DIN PA7/SPI1_MOSI
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
22 7 nOE PD4/FSMC_nOE
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
23 8 TC_DOUT PA6/SPI1_MISO
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
24 9 nWR PD5/FSMC_nWE
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
25 10 TC_INT PB6
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
26 11 CS PD7/FSMC_NE1/FSMC_NCE2
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
27 12 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
28 13 RS PD11/FSMC_A16
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
29 14 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
30 15 D7 PE10/FSMC_D7
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
31 16 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
32 17 D6 PE9/FSMC_D6
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
33 18 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
34 19 D3 PD1/FSMC_D3
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
35 20 D13 PD8/FSMC_D13
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
36 21 D5 PE8/FSMC_D5
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
37 22 D12 PE15/FSMC_D12
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
38 23 D4 PE7/FSMC_D4
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
39 24 GND
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
40 25 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
41 26 D11 PE14/FSMC_D11
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
42 27 D2 PD0/FSMC_D2
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
43 28 D10 PE13/FSMC_D10
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
44 29 D1 PD15/FSMC_D1
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
45 30 D9 PE12/FSMC_D9
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
46 31 D0 PD14/FSMC_D0
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
47 32 D14 PD9/FSMC_D14
3
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
48 33 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
49 34 D8 PE11/FSMC_D8
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
50 35 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
51 36 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
52 37 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
53 38 LCD_PWM PD13/TIM4_CH2
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
54 39 NC
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
55 40 D15 PD10/FSMC_D15
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
56 */
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
57
4
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
58 #include <stdio.h>
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
59 #include <stdint.h>
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
60 #include <stdlib.h>
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
61 #include <ctype.h>
3
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
62 #include "stm32f10x.h"
74e9b3baac1e Jumbo commit to make things work.
Daniel O'Connor <darius@dons.net.au>
parents:
diff changeset
63 #include "lcd.h"
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
64 #include "delay.h"
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
65
4
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
66 #define Bank1_LCD_C ((uint32_t)0x60000000) /* Register Address */
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
67 #define Bank1_LCD_D ((uint32_t)0x60020000) /* Data Address */
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
68
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
69 #define COLINCVAL 7968 /* 255.0 / 320.0 * 10000 */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
70
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
71 void colinc(uint16_t *mag, uint16_t *err, uint16_t amt, uint16_t max) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
72 *err += amt;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
73 if (*err > max) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
74 (*mag) = (*mag) + 1;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
75 (*err) = (*err) - max;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
76 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
77 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
78
4
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
79 void
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
80 lcd_writereg(uint16_t index, uint16_t val) {
4
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
81 *(__IO uint16_t *)(Bank1_LCD_C) = index;
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
82 *(__IO uint16_t *)(Bank1_LCD_D) = val;
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
83 }
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
84
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
85 uint16_t
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
86 lcd_readreg(uint16_t index) {
4
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
87 *(__IO uint16_t *)(Bank1_LCD_C) = index;
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
88 return(*(__IO uint16_t *)(Bank1_LCD_D));
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
89 }
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
90
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
91 uint16_t
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
92 lcd_readdata(int first) {
4
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
93 uint16_t a = 0;
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
94 if (first)
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
95 a = *(__IO uint16_t *) (Bank1_LCD_D); /* Dummy */
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
96 a = *(__IO uint16_t *) (Bank1_LCD_D); /* Read */
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
97
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
98 return (a);
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
99 }
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
100
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
101 void
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
102 lcd_startgram(uint16_t x, uint16_t y) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
103 lcd_writereg(0x20, x);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
104 lcd_writereg(0x21, y);
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
105 *(__IO uint16_t *)(Bank1_LCD_C) = 0x22; /* Start GRAM write */
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
106 }
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
107
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
108 void
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
109 lcd_writedata(uint16_t val) {
4
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
110 *(__IO uint16_t *)(Bank1_LCD_D) = val;
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
111 }
2c87e30c982d Add LCD init, touch screen writing etc..
Daniel O'Connor <darius@dons.net.au>
parents: 3
diff changeset
112
5
efa2c22266e3 PWM control LED backlight.
Daniel O'Connor <darius@dons.net.au>
parents: 4
diff changeset
113 void
efa2c22266e3 PWM control LED backlight.
Daniel O'Connor <darius@dons.net.au>
parents: 4
diff changeset
114 lcd_setpwm(uint16_t val) {
efa2c22266e3 PWM control LED backlight.
Daniel O'Connor <darius@dons.net.au>
parents: 4
diff changeset
115 TIM_OCInitTypeDef TIM_OCInitStructure;
efa2c22266e3 PWM control LED backlight.
Daniel O'Connor <darius@dons.net.au>
parents: 4
diff changeset
116
efa2c22266e3 PWM control LED backlight.
Daniel O'Connor <darius@dons.net.au>
parents: 4
diff changeset
117 /* Channel 2 configuration in PWM mode */
efa2c22266e3 PWM control LED backlight.
Daniel O'Connor <darius@dons.net.au>
parents: 4
diff changeset
118 TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
efa2c22266e3 PWM control LED backlight.
Daniel O'Connor <darius@dons.net.au>
parents: 4
diff changeset
119 TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
efa2c22266e3 PWM control LED backlight.
Daniel O'Connor <darius@dons.net.au>
parents: 4
diff changeset
120 TIM_OCInitStructure.TIM_Pulse = val;
efa2c22266e3 PWM control LED backlight.
Daniel O'Connor <darius@dons.net.au>
parents: 4
diff changeset
121 TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
efa2c22266e3 PWM control LED backlight.
Daniel O'Connor <darius@dons.net.au>
parents: 4
diff changeset
122
efa2c22266e3 PWM control LED backlight.
Daniel O'Connor <darius@dons.net.au>
parents: 4
diff changeset
123 TIM_OC2Init(TIM4, &TIM_OCInitStructure);
efa2c22266e3 PWM control LED backlight.
Daniel O'Connor <darius@dons.net.au>
parents: 4
diff changeset
124
efa2c22266e3 PWM control LED backlight.
Daniel O'Connor <darius@dons.net.au>
parents: 4
diff changeset
125 }
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
126
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
127 void
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
128 lcd_init(void) {
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
129 uint16_t id, x, y;
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
130
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
131 /* Initialise LCD panel */
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
132
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
133 /* Pull reset pin low */
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
134 delay(1);
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
135 GPIO_ResetBits(GPIOE, GPIO_Pin_1);
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
136 delay(10);
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
137 GPIO_SetBits(GPIOE, GPIO_Pin_1);
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
138 delay(50);
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
139
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
140 id = lcd_readreg(0x00);
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
141 if (id != 0x9325) {
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
142 printf("LCD ID doesn't match, expected 0x9325 got 0x%x\r\n", id);
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
143 return;
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
144 }
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
145 printf("LCD ID matches\r\n");
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
146
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
147 lcd_writereg(0x00e3, 0x3008); /* Set internal timing (not documented) */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
148 lcd_writereg(0x00e7, 0x0012); /* Set internal timing (not documented) */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
149 lcd_writereg(0x00ef, 0x1231); /* Set internal timing (not documented) */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
150 lcd_writereg(0x0000, 0x0001); /* Start Oscillation */
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
151 delay(50);
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
152 lcd_writereg(0x0001, 0x0100); /* set SS (S720 -> S1) */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
153 lcd_writereg(0x0002, 0x0700); /* set line inversion (B/C + EOR) */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
154 lcd_writereg(0x0004, 0x0000); /* no resizing */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
155 lcd_writereg(0x0008, 0x0202); /* set the back porch and front porch (2 lines each) */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
156 lcd_writereg(0x0009, 0x0000); /* set non-display area refresh cycle ISC[3:0] */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
157 lcd_writereg(0x000a, 0x0000); /* FMARK function */
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
158
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
159 lcd_writereg(0x000c, 0x0000); /* RGB ctl - Internal clock, 18bit interface */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
160 lcd_writereg(0x000d, 0x0000); /* Frame marker Position */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
161 lcd_writereg(0x000f, 0x0000); /* RGB interface polarity */
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
162
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
163 /* Power On sequence */
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
164 lcd_writereg(0x0010, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
165 lcd_writereg(0x0011, 0x0007); /* DC1[2:0], DC0[2:0], VC[2:0] */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
166 lcd_writereg(0x0012, 0x0000); /* VREG1OUT voltage */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
167 lcd_writereg(0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
168 delay(200); /* Dis-charge capacitor power voltage */
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
169 lcd_writereg(0x0010, 0x1690); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
170 lcd_writereg(0x0011, 0x0227); /* R11h = 0x0221 at VCI = 3.3V, DC1[2:0], DC0[2:0], VC[2:0] */
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
171 delay(50); /* delay 50ms */
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
172 lcd_writereg(0x0012, 0x001c); /* External reference voltage= Vci; */
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
173 delay(50); /* delay 50ms */
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
174 lcd_writereg(0x0013, 0x1800); /* R13 = 1200 when R12 = 009D; VDV[4:0] for VCOM amplitude */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
175 lcd_writereg(0x0029, 0x001c); /* R29 = 000C when R12 = 009D; VCM[5:0] for VCOMH */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
176 lcd_writereg(0x002b, 0x000d); /* Frame Rate = 91Hz */
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
177 delay(50); /* delay 50ms */
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
178
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
179 /* Set GRAM area */
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
180 lcd_writereg(0x0050, 0x0000); /* Horizontal GRAM Start Address */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
181 lcd_writereg(0x0051, 0x00ef); /* Horizontal GRAM End Address */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
182 lcd_writereg(0x0052, 0x0000); /* Vertical GRAM Start Address */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
183 lcd_writereg(0x0053, 0x013f); /* Vertical GRAM Start Address */
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
184
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
185 lcd_writereg(0x0060, 0xa700); /* Gate Scan Line, drive G320 -> G1 */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
186 lcd_writereg(0x0061, 0x0003); /* VLE & REV */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
187 lcd_writereg(0x006a, 0x0000); /* set scrolling line */
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
188
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
189 /* Partial Display Control */
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
190 lcd_writereg(0x0080, 0x0000); /* Image 1 */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
191 lcd_writereg(0x0081, 0x0000);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
192 lcd_writereg(0x0082, 0x0000);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
193 lcd_writereg(0x0083, 0x0000); /* Image 2 */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
194 lcd_writereg(0x0084, 0x0000);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
195 lcd_writereg(0x0085, 0x0000);
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
196
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
197 /* Panel Control */
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
198 lcd_writereg(0x0090, 0x0010);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
199 lcd_writereg(0x0092, 0x0000);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
200 lcd_writereg(0x0093, 0x0003);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
201 lcd_writereg(0x0095, 0x0110);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
202 lcd_writereg(0x0097, 0x0000); /* Undocumented */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
203 lcd_writereg(0x0098, 0x0000); /* Undocumented */
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
204
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
205 lcd_writereg(0x0007, 0x0133); /* Display on, 262k colour mode (vs 8) */
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
206
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
207 lcd_writereg(0x0003, 0x1030); /* set GRAM write direction and enable BGR, 64K colours, 1 transfers/pixel. */
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
208
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
209 /* Adjust the Gamma Curve */
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
210 lcd_writereg(0x0030, 0x0006);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
211 lcd_writereg(0x0031, 0x0101);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
212 lcd_writereg(0x0032, 0x0003);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
213 lcd_writereg(0x0035, 0x0106);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
214 lcd_writereg(0x0036, 0x0b02);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
215 lcd_writereg(0x0037, 0x0302);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
216 lcd_writereg(0x0038, 0x0707);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
217 lcd_writereg(0x0039, 0x0007);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
218 lcd_writereg(0x003c, 0x0600);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
219 lcd_writereg(0x003d, 0x020b);
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
220
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
221 fputs("Testing\r\n", stdout);
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
222 lcd_startgram(0, 0);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
223 lcd_writedata(0xa5a5);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
224 lcd_writedata(0x5a5a);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
225 lcd_startgram(0, 0);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
226 if ((id = lcd_readdata(1)) != 0xa5a5)
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
227 printf("Expected 0xa5a5 got 0x%04x\r\n", id);
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
228
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
229 if ((id = lcd_readdata(0)) != 0x5a5a)
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
230 printf("Expected 0x5a5a got 0x%04x\r\n", id);
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
231
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
232 fputs("Filling\r\n", stdout);
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
233 /* Fill panel */
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
234 lcd_startgram(0, 0);
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
235
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
236 for (y = 0; y < 320; y++)
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
237 for (x = 0; x < 240; x++)
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
238 lcd_writedata(LCD_BLACK);
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
239 }
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
240
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
241 void
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
242 lcd_pixel(uint16_t x, uint16_t y, uint16_t colour) {
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
243 if (x > LCD_WIDTH || y > LCD_HEIGHT)
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
244 return;
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
245
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
246 /* Rotate for landscape */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
247 lcd_startgram(y, x);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
248 lcd_writedata(colour);
7
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
249 }
9404b9869c27 Make the LCD panel work (timings, GPIOE clock needs to be on, etc)
Daniel O'Connor <darius@dons.net.au>
parents: 5
diff changeset
250
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
251 /*
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
252 * Draw a circle
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
253 * From http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
254 */
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
255 void
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
256 lcd_circle(uint16_t x0, uint16_t y0, uint16_t radius, uint8_t fill, uint16_t colour) {
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
257 int16_t f;
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
258 uint16_t ddF_x, ddF_y, x, y;
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
259
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
260 f = 1 - radius;
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
261 ddF_x = 1;
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
262 ddF_y = -2 * radius;
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
263 x = 0;
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
264 y = radius;
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
265
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
266
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
267 if (fill) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
268 lcd_line(x0, y0 + radius, x0, y0 - radius, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
269 lcd_line(x0 + radius, y0, x0 - radius, y0, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
270 } else {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
271 lcd_pixel(x0, y0 + radius, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
272 lcd_pixel(x0, y0 - radius, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
273 lcd_pixel(x0 + radius, y0, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
274 lcd_pixel(x0 - radius, y0, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
275 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
276
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
277 while(x < y) {
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
278 if(f >= 0) {
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
279 y--;
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
280 ddF_y += 2;
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
281 f += ddF_y;
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
282 }
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
283 x++;
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
284 ddF_x += 2;
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
285 f += ddF_x;
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
286 if (fill) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
287 lcd_line(x0 + x, y0 + y, x0 - x, y0 + y, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
288 lcd_line(x0 + x, y0 - y, x0 - x, y0 - y, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
289 lcd_line(x0 + y, y0 + x, x0 - y, y0 + x, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
290 lcd_line(x0 + y, y0 - x, x0 - y, y0 - x, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
291 } else {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
292 lcd_pixel(x0 + x, y0 + y, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
293 lcd_pixel(x0 - x, y0 + y, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
294 lcd_pixel(x0 + x, y0 - y, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
295 lcd_pixel(x0 - x, y0 - y, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
296 lcd_pixel(x0 + y, y0 + x, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
297 lcd_pixel(x0 - y, y0 + x, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
298 lcd_pixel(x0 + y, y0 - x, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
299 lcd_pixel(x0 - y, y0 - x, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
300 }
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
301 }
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
302 }
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
303
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
304
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
305 /*
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
306 * Draw a line
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
307 * From http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
308 */
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
309 void
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
310 lcd_line(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t colour) {
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
311 uint16_t dx, dy;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
312 int16_t sx, sy, err, e2;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
313
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
314 dx = abs(x1 - x0);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
315 dy = abs(y1 - y0);
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
316
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
317 if (x0 < x1)
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
318 sx = 1;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
319 else
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
320 sx = -1;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
321
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
322 if (y0 < y1)
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
323 sy = 1;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
324 else
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
325 sy = -1;
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
326
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
327 err = dx - dy;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
328
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
329 while (1) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
330
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
331 lcd_pixel(x0, y0, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
332
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
333 if (x0 == x1 && y0 == y1)
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
334 break;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
335
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
336 e2 = 2 * err;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
337
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
338 if (e2 > -dy) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
339 err = err - dy;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
340 x0 = x0 + sx;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
341 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
342
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
343 if (e2 < dx) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
344 err = err + dx;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
345 y0 = y0 + sy;
8
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
346 }
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
347 }
58d76cf522ff Split out code into separate files.
Daniel O'Connor <darius@dons.net.au>
parents: 7
diff changeset
348 }
9
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
349
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
350 static void
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
351 _lcd_ellipsedraw(uint16_t xc, uint16_t yc, uint16_t x, uint16_t y, uint8_t fill, uint16_t colour) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
352 if (fill) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
353 lcd_line(xc + x, yc + y, xc - x, yc + y, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
354 lcd_line(xc - x, yc - y, xc + x, yc - y, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
355 } else {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
356 lcd_pixel(xc + x, yc + y, colour); /* 1st quadrant */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
357 lcd_pixel(xc - x, yc + y, colour); /* 2nd quadrant */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
358 lcd_pixel(xc - x, yc - y, colour); /* 3rd quadrant */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
359 lcd_pixel(xc + x, yc - y, colour); /* 4th quadrant */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
360 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
361 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
362
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
363 /* Draw an ellipse, from
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
364 * http://rooparam.blogspot.com.au/2009/09/midpoint-ellipse-algorithm.html
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
365 */
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
366 void lcd_ellipse(int xc, int yc, int rx, int ry, uint8_t fill, uint16_t colour) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
367 long long int rx_2 = rx * rx, ry_2 = ry * ry;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
368 long long int p = ry_2 - rx_2 * ry + (ry_2 >> 2);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
369 int x = 0, y = ry;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
370 long long int two_ry_2_x = 0, two_rx_2_y = (rx_2 << 1) * y;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
371
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
372 _lcd_ellipsedraw(xc, yc, x, y, fill, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
373
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
374 while (two_rx_2_y >= two_ry_2_x) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
375 x++;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
376 two_ry_2_x += ry_2 << 1;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
377
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
378 p += two_ry_2_x + ry_2;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
379
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
380 if (p >= 0){
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
381 y--;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
382 two_rx_2_y -= rx_2 << 1;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
383
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
384 p -= two_rx_2_y;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
385 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
386 _lcd_ellipsedraw(xc, yc, x, y, fill, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
387 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
388
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
389 p = (long long int)(ry_2 * (x + 1 / 2.0) * (x + 1 / 2.0) + rx_2 * (y - 1) * (y - 1) - rx_2 * ry_2);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
390 while (y >= 0) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
391 p += rx_2;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
392 y--;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
393 two_rx_2_y -= rx_2 << 1;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
394 p -= two_rx_2_y;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
395
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
396 if (p <= 0) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
397 x++;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
398 two_ry_2_x += ry_2 << 1;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
399 p += two_ry_2_x;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
400 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
401 _lcd_ellipsedraw(xc, yc, x, y, fill, colour);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
402 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
403 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
404
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
405 void lcd_stripes(void) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
406 uint16_t x, y, mag, err;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
407
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
408 lcd_startgram(0, 0);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
409
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
410 mag = err = 0;
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
411 for (y = 0; y < 320; y++) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
412 for (x = 0; x < 240; x++) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
413 if (((x / 80) % 3) == 0) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
414 lcd_writedata(RGB24_565(mag, 0, 0));
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
415 } else if (((x / 80) % 3) == 1) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
416 lcd_writedata(RGB24_565(0, mag, 0));
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
417 } else {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
418 lcd_writedata(RGB24_565(0, 0, mag));
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
419 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
420 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
421 colinc(&mag, &err, COLINCVAL, 10000);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
422 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
423 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
424 uint16_t
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
425 lcd_parsecol(char c) {
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
426 c = toupper(c);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
427 if (c == 'R')
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
428 return(LCD_RED);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
429 else if (c == 'G')
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
430 return(LCD_GREEN);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
431 else if (c == 'B')
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
432 return(LCD_BLUE);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
433 else if (c == 'L')
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
434 return(LCD_BLACK);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
435 else
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
436 return(LCD_WHITE);
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
437
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
438 }
be0a1ac64d97 - Add ellipse drawing.
Daniel O'Connor <darius@dons.net.au>
parents: 8
diff changeset
439