TFT

Dependencies:   mbed

Fork of Ovation_Controller_1 by Andrew R

Committer:
bf1891
Date:
Thu Aug 28 15:18:07 2014 +0000
Revision:
3:92845c139aca
Parent:
2:67e16df2c89a
publish;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewcrussell 1:ecf8078bf531 1 /***********************************************************************************/
andrewcrussell 1:ecf8078bf531 2 /***** Newhaven NHD-5.7-640480WF-CTXL# Display Driver **********/
andrewcrussell 1:ecf8078bf531 3 /***** for mbed (www.mbed,org) NXP LPC1768 32 bit ARM MCU ******/
andrewcrussell 1:ecf8078bf531 4 /********* Adapted by Andrew C. Russell, March 2011 ***********/
andrewcrussell 1:ecf8078bf531 5
andrewcrussell 1:ecf8078bf531 6 /************I hereby acknowledge and thank the following ******/
andrewcrussell 1:ecf8078bf531 7 /***software authors whose code I have adapted and/or adopted***/
andrewcrussell 1:ecf8078bf531 8 /*******************to create these drivers:- ******************/
andrewcrussell 1:ecf8078bf531 9
andrewcrussell 1:ecf8078bf531 10 //Curt Lagerstam - Newhaven Display International, LLC for the dispay initialization.
andrewcrussell 1:ecf8078bf531 11 //James P Lynch - code adapted from his Nokia LCD display tutorial at
andrewcrussell 1:ecf8078bf531 12 //http://www.sparkfun.com/tutorial/Nokia%206100%20LCD%20Display%20Driver.pdf
andrewcrussell 1:ecf8078bf531 13 //Akifumi 'Tedd' Okano for assistance and adapting the .bmp display driver and writing
andrewcrussell 1:ecf8078bf531 14 //the driver for the font display
andrewcrussell 1:ecf8078bf531 15 /***********************************************************************************/
andrewcrussell 1:ecf8078bf531 16
andrewcrussell 1:ecf8078bf531 17 //#include "mbed.h"
andrewcrussell 1:ecf8078bf531 18 //#include "font_1.h"
andrewcrussell 1:ecf8078bf531 19 //#include "stdlib.h"
andrewcrussell 1:ecf8078bf531 20 //#include "string.h"
andrewcrussell 1:ecf8078bf531 21 //#include "math.h"
andrewcrussell 1:ecf8078bf531 22 #include "font_new.h"
andrewcrussell 1:ecf8078bf531 23 //#include "system_defines.h"
andrewcrussell 1:ecf8078bf531 24
andrewcrussell 1:ecf8078bf531 25 /***********************************************************************************/
andrewcrussell 1:ecf8078bf531 26 /********************************** Colors *****************************************/
andrewcrussell 1:ecf8078bf531 27 /********* taken directly from http://web.njit.edu/~kevin/rgb.txt.html**************/
andrewcrussell 1:ecf8078bf531 28 #define BLACK 0x000000
andrewcrussell 1:ecf8078bf531 29 #define WHITE 0xFFFFFF
andrewcrussell 1:ecf8078bf531 30 #define BLACK 0x000000
andrewcrussell 1:ecf8078bf531 31 #define RED 0xFF0000
andrewcrussell 1:ecf8078bf531 32 #define GREEN 0x00FF00
andrewcrussell 1:ecf8078bf531 33 #define LGREEN 0xCCFF00 //light green
andrewcrussell 1:ecf8078bf531 34 #define BLUE 0x0000FF
andrewcrussell 1:ecf8078bf531 35 #define GREY 0xBEBEBE
andrewcrussell 1:ecf8078bf531 36 #define DEEPINK 0xFF1493
andrewcrussell 1:ecf8078bf531 37 #define YELLOW 0xFFFF00
andrewcrussell 1:ecf8078bf531 38 #define LORANGE 0xFFFF00 //light orange
andrewcrussell 1:ecf8078bf531 39 #define DORANGE 0xFF9900 //dark orange
andrewcrussell 1:ecf8078bf531 40 #define OLIVE 0x999900
andrewcrussell 1:ecf8078bf531 41
andrewcrussell 1:ecf8078bf531 42 #define PASET 0x2B
andrewcrussell 1:ecf8078bf531 43 #define CASET 0x2A
andrewcrussell 1:ecf8078bf531 44 #define DISON 0x29
andrewcrussell 1:ecf8078bf531 45 #define DISOFF 0x28
andrewcrussell 1:ecf8078bf531 46 #define DEEPSLEEP 0xE5
andrewcrussell 1:ecf8078bf531 47 #define RAMWR 0x2C
andrewcrussell 1:ecf8078bf531 48 #define RAMCT 0x3C
andrewcrussell 1:ecf8078bf531 49 #define RESET 0x01
andrewcrussell 1:ecf8078bf531 50 #define DISINV 0x21
andrewcrussell 1:ecf8078bf531 51 #define DISNOR 0x20
andrewcrussell 1:ecf8078bf531 52 #define NOP 0x00
andrewcrussell 2:67e16df2c89a 53 #define XMAX 640 // x axis max pixels
andrewcrussell 2:67e16df2c89a 54 #define YMAX 480 // y axis max pixels
andrewcrussell 1:ecf8078bf531 55 #define TRUE 1
andrewcrussell 2:67e16df2c89a 56 #define SPAN 460 //this is for the slider bar
andrewcrussell 1:ecf8078bf531 57 #define ZERO 100
andrewcrussell 1:ecf8078bf531 58 #define PI 3.14159265
andrewcrussell 1:ecf8078bf531 59
andrewcrussell 1:ecf8078bf531 60 // Font sizes
andrewcrussell 1:ecf8078bf531 61 #define SMALL 0
andrewcrussell 1:ecf8078bf531 62 #define MEDIUM 1
andrewcrussell 1:ecf8078bf531 63 #define LARGE 2
andrewcrussell 1:ecf8078bf531 64 #define LARGE1 3
andrewcrussell 1:ecf8078bf531 65 /********************************************************************/
andrewcrussell 1:ecf8078bf531 66 #ifdef TEST
andrewcrussell 1:ecf8078bf531 67 extern unsigned char screen[ SC_WIDTH * SC_HEIGHT ] = { '.' };
andrewcrussell 1:ecf8078bf531 68 #endif
andrewcrussell 1:ecf8078bf531 69 /********************************************************************/
andrewcrussell 1:ecf8078bf531 70 //unsigned char FONT6x8[97][8];
andrewcrussell 1:ecf8078bf531 71 //unsigned char FONT8x8[97][8];
andrewcrussell 1:ecf8078bf531 72 //unsigned char FONT8x16[97][8];
andrewcrussell 1:ecf8078bf531 73 /************ here the XY reference locations for the buttons ************/
andrewcrussell 2:67e16df2c89a 74 int righttbutinc=80;
andrewcrussell 1:ecf8078bf531 75 int xref2=590; //right hand side button x reference
andrewcrussell 1:ecf8078bf531 76 int xref1=16; //left hand side button x reference
andrewcrussell 1:ecf8078bf531 77 int leftbutinc=76; //y axis increment for the left hand side buttons
andrewcrussell 1:ecf8078bf531 78 int yref1=70;
andrewcrussell 1:ecf8078bf531 79 int xbutsize1=60; // x size of button
andrewcrussell 1:ecf8078bf531 80 int ybutsize1=50; // y size of button
andrewcrussell 1:ecf8078bf531 81 /************************************************************************/
andrewcrussell 1:ecf8078bf531 82 unsigned char command;
andrewcrussell 1:ecf8078bf531 83 unsigned char data1;
andrewcrussell 1:ecf8078bf531 84 int DOWN;
andrewcrussell 1:ecf8078bf531 85 int RIGHT;
andrewcrussell 1:ecf8078bf531 86 int color;
andrewcrussell 1:ecf8078bf531 87 unsigned int fill;
andrewcrussell 1:ecf8078bf531 88 unsigned int radius;
andrewcrussell 1:ecf8078bf531 89 int z;
andrewcrussell 2:67e16df2c89a 90 int color1;
andrewcrussell 2:67e16df2c89a 91 int color2;
andrewcrussell 1:ecf8078bf531 92 //float slider;
andrewcrussell 1:ecf8078bf531 93 //float vol;
andrewcrussell 1:ecf8078bf531 94
andrewcrussell 1:ecf8078bf531 95 /**************************** forward references *******************************/
andrewcrussell 1:ecf8078bf531 96 void LCDSetXY(int x, int y);
andrewcrussell 1:ecf8078bf531 97 void LCDClearScreen(void);
andrewcrussell 1:ecf8078bf531 98 void LCDSetPixel(int x, int y, int color);
andrewcrussell 1:ecf8078bf531 99 void LCDSetLine(int x1, int y1, int x2, int y2, int color);
andrewcrussell 1:ecf8078bf531 100 void LCDSetRect(int x0, int y0, int x1, int y1, int fill, int color);
andrewcrussell 1:ecf8078bf531 101 void LCDSetCircle(int x0, int y0, int radius, int color);
andrewcrussell 1:ecf8078bf531 102 void LCDPutChar(char c, int x, int y, int size, int fcolor, int bcolor);
andrewcrussell 1:ecf8078bf531 103 void LCDPutString (char *lcd_string, const char *font_style, unsigned char x, unsigned char y,
andrewcrussell 1:ecf8078bf531 104 unsigned char fcolor, unsigned char bcolor);
andrewcrussell 1:ecf8078bf531 105 void trigcircle (int xtc, int ytc, int radius, int color);
andrewcrussell 2:67e16df2c89a 106 void show_screen( int xs, int width, int ys, int height );
andrewcrussell 1:ecf8078bf531 107 void volume_slider (int volume);
andrewcrussell 2:67e16df2c89a 108 void mute (unsigned int onoff);
andrewcrussell 1:ecf8078bf531 109 //************************************************************************************
andrewcrussell 1:ecf8078bf531 110
andrewcrussell 1:ecf8078bf531 111 void Write_Command(unsigned char command) {
andrewcrussell 1:ecf8078bf531 112 CS=1; /* just to make sure */
andrewcrussell 1:ecf8078bf531 113 nRD = 1; /* make sure the RD is HIGH just to be sure */
andrewcrussell 1:ecf8078bf531 114 DC=0;
andrewcrussell 1:ecf8078bf531 115 nWR = 0;
andrewcrussell 1:ecf8078bf531 116 CS=0;
andrewcrussell 1:ecf8078bf531 117 //data_bus_write(command);
andrewcrussell 1:ecf8078bf531 118 DB=command;
andrewcrussell 1:ecf8078bf531 119 CS = 1;
andrewcrussell 1:ecf8078bf531 120 nWR = 1;
andrewcrussell 1:ecf8078bf531 121 }
andrewcrussell 1:ecf8078bf531 122 //;******************************************************************************
andrewcrussell 1:ecf8078bf531 123 //void Write_Data(unsigned char data1) {
andrewcrussell 1:ecf8078bf531 124 void Write_Data(int data1) {
andrewcrussell 1:ecf8078bf531 125 CS=1; /* just to make sure */
andrewcrussell 1:ecf8078bf531 126 nRD = 1;
andrewcrussell 1:ecf8078bf531 127 DC=1;
andrewcrussell 1:ecf8078bf531 128 nWR = 0;
andrewcrussell 1:ecf8078bf531 129 CS=0;
andrewcrussell 1:ecf8078bf531 130 //data_bus_write(data1);
andrewcrussell 1:ecf8078bf531 131 DB=data1;//write(data1);
andrewcrussell 1:ecf8078bf531 132 CS = 1;
andrewcrussell 1:ecf8078bf531 133 nWR = 1;
andrewcrussell 1:ecf8078bf531 134 }
andrewcrussell 1:ecf8078bf531 135 //====================================================
andrewcrussell 1:ecf8078bf531 136 void Command_Write(unsigned char REG,unsigned char VALUE) {
andrewcrussell 1:ecf8078bf531 137 Write_Command(REG);
andrewcrussell 1:ecf8078bf531 138 Write_Data(VALUE);
andrewcrussell 1:ecf8078bf531 139 }
andrewcrussell 1:ecf8078bf531 140 //======================================================
andrewcrussell 1:ecf8078bf531 141 void SendData(unsigned long color) {
andrewcrussell 1:ecf8078bf531 142 Write_Data((color)>>16); //red
andrewcrussell 1:ecf8078bf531 143 Write_Data((color)>>8); //green
andrewcrussell 1:ecf8078bf531 144 Write_Data(color); //blue
andrewcrussell 1:ecf8078bf531 145 }
andrewcrussell 1:ecf8078bf531 146 /********************************************************************************/
andrewcrussell 1:ecf8078bf531 147 // initialize the SSD1963 controller
andrewcrussell 1:ecf8078bf531 148 void Init_SSD1963 (void) {
andrewcrussell 1:ecf8078bf531 149 Write_Command(0x01); //Software Reset
andrewcrussell 1:ecf8078bf531 150 wait_ms(10);
andrewcrussell 1:ecf8078bf531 151 Write_Command(0x01); //Software Reset
andrewcrussell 1:ecf8078bf531 152 wait_ms(10);
andrewcrussell 1:ecf8078bf531 153 Write_Command(0x01); //Software Reset
andrewcrussell 1:ecf8078bf531 154 wait_ms(10);
andrewcrussell 1:ecf8078bf531 155 Command_Write(0xe0,0x01); //START PLL
andrewcrussell 1:ecf8078bf531 156 wait_us(1);
andrewcrussell 1:ecf8078bf531 157 Command_Write(0xe0,0x03); //LOCK PLL
andrewcrussell 1:ecf8078bf531 158 Write_Command(0xb0); //SET LCD MODE SET TFT 18Bits MODE
andrewcrussell 1:ecf8078bf531 159 Write_Data(0x0c); //SET TFT MODE & hsync+Vsync+DEN MODE
andrewcrussell 1:ecf8078bf531 160 Write_Data(0x80); //SET TFT MODE & hsync+Vsync+DEN MODE
andrewcrussell 1:ecf8078bf531 161 Write_Data(0x02); //SET horizontal size=640-1 HightByte
andrewcrussell 1:ecf8078bf531 162 Write_Data(0x7f); //SET horizontal size=640-1 LowByte
andrewcrussell 1:ecf8078bf531 163 Write_Data(0x01); //SET vertical size=480-1 HightByte
andrewcrussell 1:ecf8078bf531 164 Write_Data(0xdf); //SET vertical size=480-1 LowByte
andrewcrussell 1:ecf8078bf531 165 Write_Data(0x00); //SET even/odd line RGB seq.=RGB
andrewcrussell 1:ecf8078bf531 166 Command_Write(0xf0,0x00); //SET pixel data I/F format=8bit
andrewcrussell 1:ecf8078bf531 167 Command_Write(0x3a,0x60); // SET R G B format = 6 6 6
andrewcrussell 1:ecf8078bf531 168 Write_Command(0xe6); //SET PCLK freq=4.94MHz ; pixel clock frequency
andrewcrussell 1:ecf8078bf531 169 Write_Data(0x02);
andrewcrussell 1:ecf8078bf531 170 Write_Data(0xff);
andrewcrussell 1:ecf8078bf531 171 Write_Data(0xff);
andrewcrussell 1:ecf8078bf531 172 Write_Command(0xb4); //SET HBP,
andrewcrussell 1:ecf8078bf531 173 Write_Data(0x02); //SET HSYNC Total=760
andrewcrussell 1:ecf8078bf531 174 Write_Data(0xf8);
andrewcrussell 1:ecf8078bf531 175 Write_Data(0x00); //SET HBP 68
andrewcrussell 1:ecf8078bf531 176 Write_Data(0x44);
andrewcrussell 1:ecf8078bf531 177 Write_Data(0x0f); //SET VBP 16=15+1
andrewcrussell 1:ecf8078bf531 178 Write_Data(0x00); //SET Hsync pulse start position
andrewcrussell 1:ecf8078bf531 179 Write_Data(0x00);
andrewcrussell 1:ecf8078bf531 180 Write_Data(0x00); //SET Hsync pulse subpixel start position
andrewcrussell 1:ecf8078bf531 181 Write_Command(0xb6); //SET VBP,
andrewcrussell 1:ecf8078bf531 182 Write_Data(0x01); //SET Vsync total
andrewcrussell 1:ecf8078bf531 183 Write_Data(0xf8);
andrewcrussell 1:ecf8078bf531 184 Write_Data(0x00); //SET VBP=19
andrewcrussell 1:ecf8078bf531 185 Write_Data(0x13);
andrewcrussell 1:ecf8078bf531 186 Write_Data(0x07); //SET Vsync pulse 8=7+1
andrewcrussell 1:ecf8078bf531 187 Write_Data(0x00); //SET Vsync pulse start position
andrewcrussell 1:ecf8078bf531 188 Write_Data(0x00);
andrewcrussell 1:ecf8078bf531 189 Write_Command(0x2a); //SET column address
andrewcrussell 1:ecf8078bf531 190 Write_Data(0x00); //SET start column address=0
andrewcrussell 1:ecf8078bf531 191 Write_Data(0x00);
andrewcrussell 1:ecf8078bf531 192 Write_Data(0x02); //SET end column address=639
andrewcrussell 1:ecf8078bf531 193 Write_Data(0x7f);
andrewcrussell 1:ecf8078bf531 194 Write_Command(0x2b); //SET page address
andrewcrussell 1:ecf8078bf531 195 Write_Data(0x00); //SET start page address=0
andrewcrussell 1:ecf8078bf531 196 Write_Data(0x00);
andrewcrussell 1:ecf8078bf531 197 Write_Data(0x01); //SET end page address=479
andrewcrussell 1:ecf8078bf531 198 Write_Data(0xdf);
andrewcrussell 1:ecf8078bf531 199 Write_Command(0x29); //SET display on
andrewcrussell 1:ecf8078bf531 200 }
andrewcrussell 1:ecf8078bf531 201
andrewcrussell 1:ecf8078bf531 202
andrewcrussell 1:ecf8078bf531 203 /********************************************************************************/
andrewcrussell 1:ecf8078bf531 204 void WindowSet( int s_x,int e_x,int s_y,int e_y) {
andrewcrussell 1:ecf8078bf531 205 Write_Command(CASET); //SET page address
andrewcrussell 1:ecf8078bf531 206 Write_Data((s_x)>>8); //SET start page address=0
andrewcrussell 1:ecf8078bf531 207 Write_Data(s_x);
andrewcrussell 1:ecf8078bf531 208 Write_Data((e_x)>>8); //SET end page address=639
andrewcrussell 1:ecf8078bf531 209 Write_Data(e_x);
andrewcrussell 1:ecf8078bf531 210 Write_Command(PASET); //SET column address
andrewcrussell 1:ecf8078bf531 211 Write_Data((s_y)>>8); //SET start column address=0
andrewcrussell 1:ecf8078bf531 212 Write_Data(s_y);
andrewcrussell 1:ecf8078bf531 213 Write_Data((e_y)>>8); //SET end column address=479
andrewcrussell 1:ecf8078bf531 214 Write_Data(e_y);
andrewcrussell 1:ecf8078bf531 215 }
andrewcrussell 1:ecf8078bf531 216 /***************************************************************************/
andrewcrussell 1:ecf8078bf531 217 /* this routine locates the screen pointer at position XY in the frame buffer */
andrewcrussell 1:ecf8078bf531 218 void LCDSetXY(int x, int y) {
andrewcrussell 1:ecf8078bf531 219 Write_Command(CASET); //SET page address
andrewcrussell 1:ecf8078bf531 220 Write_Data((x)>>8); //SET start page address=0
andrewcrussell 1:ecf8078bf531 221 Write_Data(x);
andrewcrussell 1:ecf8078bf531 222 Write_Data((XMAX)>>8); //SET end page address=XMAX
andrewcrussell 1:ecf8078bf531 223 Write_Data(XMAX);
andrewcrussell 1:ecf8078bf531 224 Write_Command(PASET); //SET column address
andrewcrussell 1:ecf8078bf531 225 Write_Data((y)>>8); //SET start column address=0
andrewcrussell 1:ecf8078bf531 226 Write_Data(y);
andrewcrussell 1:ecf8078bf531 227 Write_Data((YMAX)>>8); //SET end column address=YMAX
andrewcrussell 1:ecf8078bf531 228 Write_Data(YMAX);
andrewcrussell 1:ecf8078bf531 229 Write_Command(RAMWR); //ready to now start writing the data
andrewcrussell 1:ecf8078bf531 230 //when returnung to the caller
andrewcrussell 1:ecf8078bf531 231 }
andrewcrussell 1:ecf8078bf531 232
andrewcrussell 1:ecf8078bf531 233
andrewcrussell 1:ecf8078bf531 234 /********************************************************************************/
andrewcrussell 1:ecf8078bf531 235 void clear_to_color(int color) {
andrewcrussell 1:ecf8078bf531 236 int m,n;
andrewcrussell 1:ecf8078bf531 237 WindowSet(0,640,0,480); // 0-640 wide by 0-480 high
andrewcrussell 1:ecf8078bf531 238 Write_Command(RAMWR);
andrewcrussell 1:ecf8078bf531 239 for (m=0;m<481;m++) {
andrewcrussell 1:ecf8078bf531 240 for (n=0;n<641;n++) {
andrewcrussell 1:ecf8078bf531 241 SendData(color);
andrewcrussell 1:ecf8078bf531 242 }
andrewcrussell 1:ecf8078bf531 243 }
andrewcrussell 1:ecf8078bf531 244 }
andrewcrussell 1:ecf8078bf531 245 /**********************************************************************************/
andrewcrussell 1:ecf8078bf531 246 /********** this routine lights up a single pixel to a specific colour ***********/
andrewcrussell 1:ecf8078bf531 247 void LCDSetPixel(int x,int y, int color) {
andrewcrussell 1:ecf8078bf531 248 Write_Command(CASET); //SET page address
andrewcrussell 1:ecf8078bf531 249 Write_Data((x)>>8); //SET start page address=0
andrewcrussell 1:ecf8078bf531 250 Write_Data(x);
andrewcrussell 1:ecf8078bf531 251 Write_Data((XMAX)>>8); //SET end page address=XMAX
andrewcrussell 1:ecf8078bf531 252 Write_Data(XMAX);
andrewcrussell 1:ecf8078bf531 253 Write_Command(PASET); //SET column address
andrewcrussell 1:ecf8078bf531 254 Write_Data((y)>>8); //SET start column address=0
andrewcrussell 1:ecf8078bf531 255 Write_Data(y);
andrewcrussell 1:ecf8078bf531 256 Write_Data((YMAX)>>8); //SET end column address=YMAX
andrewcrussell 1:ecf8078bf531 257 Write_Data(YMAX);
andrewcrussell 1:ecf8078bf531 258 Write_Command(RAMWR); //ready to now start writing the data
andrewcrussell 1:ecf8078bf531 259 //when returnung to the caller
andrewcrussell 1:ecf8078bf531 260 SendData(color);
andrewcrussell 1:ecf8078bf531 261 Write_Command(NOP);
andrewcrussell 1:ecf8078bf531 262 }
andrewcrussell 1:ecf8078bf531 263 /*********************************************************************************/
andrewcrussell 1:ecf8078bf531 264 /************ This routine draws a line between 2 points on the screen ***********/
andrewcrussell 1:ecf8078bf531 265 void LCDSetLine(int x0, int y0, int x1,int y1, int color) {
andrewcrussell 1:ecf8078bf531 266 int dy = y1 - y0;
andrewcrussell 1:ecf8078bf531 267 int dx = x1 - x0;
andrewcrussell 1:ecf8078bf531 268 int stepx, stepy;
andrewcrussell 1:ecf8078bf531 269 if (dy < 0) {
andrewcrussell 1:ecf8078bf531 270 dy = -dy;
andrewcrussell 1:ecf8078bf531 271 stepy = -1;
andrewcrussell 1:ecf8078bf531 272 } else {
andrewcrussell 1:ecf8078bf531 273 stepy = 1;
andrewcrussell 1:ecf8078bf531 274 }
andrewcrussell 1:ecf8078bf531 275 if (dx < 0) {
andrewcrussell 1:ecf8078bf531 276 dx = -dx;
andrewcrussell 1:ecf8078bf531 277 stepx = -1;
andrewcrussell 1:ecf8078bf531 278 } else {
andrewcrussell 1:ecf8078bf531 279 stepx = 1;
andrewcrussell 1:ecf8078bf531 280 }
andrewcrussell 1:ecf8078bf531 281 dy <<= 1; // dy is now 2*dy
andrewcrussell 1:ecf8078bf531 282 dx <<= 1; // dx is now 2*dx
andrewcrussell 1:ecf8078bf531 283 LCDSetPixel(x0, y0, color);
andrewcrussell 1:ecf8078bf531 284 if (dx > dy) {
andrewcrussell 1:ecf8078bf531 285 int fraction = dy - (dx >> 1); // same as 2*dy - dx
andrewcrussell 1:ecf8078bf531 286 while (x0 != x1) {
andrewcrussell 1:ecf8078bf531 287 if (fraction >= 0) {
andrewcrussell 1:ecf8078bf531 288 y0 += stepy;
andrewcrussell 1:ecf8078bf531 289 fraction -= dx; // same as fraction -= 2*dx
andrewcrussell 1:ecf8078bf531 290 }
andrewcrussell 1:ecf8078bf531 291 x0 += stepx;
andrewcrussell 1:ecf8078bf531 292 fraction += dy; // same as fraction -= 2*dy
andrewcrussell 1:ecf8078bf531 293 LCDSetPixel(x0, y0, color);
andrewcrussell 1:ecf8078bf531 294 }
andrewcrussell 1:ecf8078bf531 295 } else {
andrewcrussell 1:ecf8078bf531 296 int fraction = dx - (dy >> 1);
andrewcrussell 1:ecf8078bf531 297 while (y0 != y1) {
andrewcrussell 1:ecf8078bf531 298 if (fraction >= 0) {
andrewcrussell 1:ecf8078bf531 299 x0 += stepx;
andrewcrussell 1:ecf8078bf531 300 fraction -= dy;
andrewcrussell 1:ecf8078bf531 301 }
andrewcrussell 1:ecf8078bf531 302 y0 += stepy;
andrewcrussell 1:ecf8078bf531 303 fraction += dx;
andrewcrussell 1:ecf8078bf531 304 LCDSetPixel(x0, y0, color);
andrewcrussell 1:ecf8078bf531 305 }
andrewcrussell 1:ecf8078bf531 306 }
andrewcrussell 1:ecf8078bf531 307 }
andrewcrussell 1:ecf8078bf531 308 /*******************************************************************************/
andrewcrussell 1:ecf8078bf531 309 /************** draw a rectangle, filled or not filled *************************/
andrewcrussell 1:ecf8078bf531 310 void LCDSetRect(int x0, int y0, int x1,int y1, int fill, int color) {
andrewcrussell 2:67e16df2c89a 311 int xmin, xmax, ymin, ymax;
andrewcrussell 1:ecf8078bf531 312 int i;
andrewcrussell 1:ecf8078bf531 313 // check if the rectangle is to be filled
andrewcrussell 1:ecf8078bf531 314 if (fill == TRUE) {
andrewcrussell 1:ecf8078bf531 315 // calculate the min and max for x and y directions
andrewcrussell 1:ecf8078bf531 316 xmin = (x0 <= x1) ? x0 : x1;
andrewcrussell 1:ecf8078bf531 317 xmax = (x0 > x1) ? x0 : x1;
andrewcrussell 1:ecf8078bf531 318 ymin = (y0 <= y1) ? y0 : y1;
andrewcrussell 1:ecf8078bf531 319 ymax = (y0 > y1) ? y0 : y1;
andrewcrussell 1:ecf8078bf531 320 Write_Command(CASET); //SET page address
andrewcrussell 1:ecf8078bf531 321 Write_Data((x0)>>8); //SET start page address=0
andrewcrussell 1:ecf8078bf531 322 Write_Data(x0);
andrewcrussell 1:ecf8078bf531 323 Write_Data((x1)>>8); //SET end page address=XMAX
andrewcrussell 1:ecf8078bf531 324 Write_Data(x1);
andrewcrussell 1:ecf8078bf531 325 Write_Command(PASET); //SET column address
andrewcrussell 1:ecf8078bf531 326 Write_Data((y0)>>8); //SET start column address=0
andrewcrussell 1:ecf8078bf531 327 Write_Data(y0);
andrewcrussell 1:ecf8078bf531 328 Write_Data((y1)>>8); //SET end column address=YMAX
andrewcrussell 1:ecf8078bf531 329 Write_Data(y1);
andrewcrussell 1:ecf8078bf531 330 Write_Command(RAMWR); //ready to now start writing the data
andrewcrussell 1:ecf8078bf531 331 for (i = 0; i < ((((xmax - xmin + 1) * (ymax - ymin + 1))) + 1); i++) {
andrewcrussell 1:ecf8078bf531 332 SendData(color);
andrewcrussell 1:ecf8078bf531 333 }
andrewcrussell 1:ecf8078bf531 334 } else {
andrewcrussell 1:ecf8078bf531 335 LCDSetLine(x0, y0, x1, y0, color);
andrewcrussell 1:ecf8078bf531 336 LCDSetLine(x0, y1, x1, y1, color);
andrewcrussell 1:ecf8078bf531 337 LCDSetLine(x0, y0, x0, y1, color);
andrewcrussell 1:ecf8078bf531 338 LCDSetLine(x1, y0, x1, y1, color);
andrewcrussell 1:ecf8078bf531 339 }
andrewcrussell 1:ecf8078bf531 340 }
andrewcrussell 1:ecf8078bf531 341 /***************************************************************************/
andrewcrussell 1:ecf8078bf531 342 void LCDSetCircle(int x0, int y0, int radius, int color) {
andrewcrussell 1:ecf8078bf531 343 int f = 1 - radius;
andrewcrussell 1:ecf8078bf531 344 int ddF_x = 0;
andrewcrussell 1:ecf8078bf531 345 int ddF_y = -2 * radius;
andrewcrussell 1:ecf8078bf531 346 int x = 0;
andrewcrussell 1:ecf8078bf531 347 int y = radius;
andrewcrussell 1:ecf8078bf531 348 LCDSetPixel(x0, y0 + radius, color);
andrewcrussell 1:ecf8078bf531 349 LCDSetPixel(x0, y0 - radius, color);
andrewcrussell 1:ecf8078bf531 350 LCDSetPixel(x0 + radius, y0, color);
andrewcrussell 1:ecf8078bf531 351 LCDSetPixel(x0 - radius, y0, color);
andrewcrussell 1:ecf8078bf531 352 while (x < y) {
andrewcrussell 1:ecf8078bf531 353 if (f >= 0) {
andrewcrussell 1:ecf8078bf531 354 y--;
andrewcrussell 1:ecf8078bf531 355 ddF_y += 2;
andrewcrussell 1:ecf8078bf531 356 f += ddF_y;
andrewcrussell 1:ecf8078bf531 357 }
andrewcrussell 1:ecf8078bf531 358 x++;
andrewcrussell 1:ecf8078bf531 359 ddF_x += 2;
andrewcrussell 1:ecf8078bf531 360 f += ddF_x + 1;
andrewcrussell 1:ecf8078bf531 361 LCDSetPixel(x0 + x, y0 + y, color);
andrewcrussell 1:ecf8078bf531 362 LCDSetPixel(x0 - x, y0 + y, color);
andrewcrussell 1:ecf8078bf531 363 LCDSetPixel(x0 + x, y0 - y, color);
andrewcrussell 1:ecf8078bf531 364 LCDSetPixel(x0 - x, y0 - y, color);
andrewcrussell 1:ecf8078bf531 365 LCDSetPixel(x0 + y, y0 + x, color);
andrewcrussell 1:ecf8078bf531 366 LCDSetPixel(x0 - y, y0 + x, color);
andrewcrussell 1:ecf8078bf531 367 LCDSetPixel(x0 + y, y0 - x, color);
andrewcrussell 1:ecf8078bf531 368 LCDSetPixel(x0 - y, y0 - x, color);
andrewcrussell 1:ecf8078bf531 369 }
andrewcrussell 1:ecf8078bf531 370 }
andrewcrussell 1:ecf8078bf531 371 /***************************************************************************/
andrewcrussell 1:ecf8078bf531 372 /***************** this is the mini-font version ***************************/
andrewcrussell 1:ecf8078bf531 373 void LCDPutChar(char c, int x, int y, int size, int fColor, int bColor) {
andrewcrussell 1:ecf8078bf531 374 extern const unsigned char FONT6x8[97][8];
andrewcrussell 1:ecf8078bf531 375 extern const unsigned char FONT8x8[97][8];
andrewcrussell 1:ecf8078bf531 376 extern const unsigned char FONT8x16[97][16];
andrewcrussell 1:ecf8078bf531 377 extern const unsigned char FONT24x59[1][177];
andrewcrussell 1:ecf8078bf531 378
andrewcrussell 1:ecf8078bf531 379 int i,j;
andrewcrussell 1:ecf8078bf531 380 unsigned int nCols;
andrewcrussell 1:ecf8078bf531 381 unsigned int nRows;
andrewcrussell 1:ecf8078bf531 382 unsigned int nBytes;
andrewcrussell 1:ecf8078bf531 383 unsigned char PixelRow;
andrewcrussell 1:ecf8078bf531 384 unsigned char Mask;
andrewcrussell 1:ecf8078bf531 385 unsigned int Word0;
andrewcrussell 1:ecf8078bf531 386 unsigned char *pFont;
andrewcrussell 1:ecf8078bf531 387 unsigned char *pChar;
andrewcrussell 1:ecf8078bf531 388 unsigned char *FontTable[] = {
andrewcrussell 1:ecf8078bf531 389 (unsigned char *)FONT6x8,
andrewcrussell 1:ecf8078bf531 390 (unsigned char *)FONT8x8,
andrewcrussell 1:ecf8078bf531 391 (unsigned char *)FONT8x16,
andrewcrussell 1:ecf8078bf531 392 (unsigned char *)FONT24x59 // I added this - it is just for the zero
andrewcrussell 1:ecf8078bf531 393 };
andrewcrussell 1:ecf8078bf531 394 // get pointer to the beginning of the selected font table
andrewcrussell 1:ecf8078bf531 395 pFont = (unsigned char *)FontTable[size];
andrewcrussell 1:ecf8078bf531 396 // get the nColumns, nRows and nBytes in the font table
andrewcrussell 1:ecf8078bf531 397 nCols = *pFont;
andrewcrussell 1:ecf8078bf531 398 nRows = *(pFont + 1);
andrewcrussell 1:ecf8078bf531 399 nBytes = *(pFont + 2);
andrewcrussell 1:ecf8078bf531 400 // get pointer to the last byte of the desired character - i.e. last byte in the row
andrewcrussell 1:ecf8078bf531 401 pChar = pFont + (nBytes * (c - 0x1F)) + nBytes - 1;
andrewcrussell 1:ecf8078bf531 402
andrewcrussell 1:ecf8078bf531 403 WindowSet( x, (x + nRows - 1), y, (y + nCols - 1) ); // set window (drawing rectangle) to font size
andrewcrussell 1:ecf8078bf531 404 Write_Command(RAMWR);
andrewcrussell 1:ecf8078bf531 405
andrewcrussell 1:ecf8078bf531 406 for ( i = (nRows - 1); i >= 0; i-- ) {
andrewcrussell 1:ecf8078bf531 407 PixelRow = *pChar--;
andrewcrussell 1:ecf8078bf531 408 Mask = 0x80;
andrewcrussell 1:ecf8078bf531 409
andrewcrussell 1:ecf8078bf531 410 for ( j = 0; j < nCols; j++ ) {
andrewcrussell 1:ecf8078bf531 411
andrewcrussell 1:ecf8078bf531 412 Word0 = (PixelRow & Mask) ? fColor : bColor;
andrewcrussell 1:ecf8078bf531 413 Mask = Mask >> 1;
andrewcrussell 1:ecf8078bf531 414
andrewcrussell 1:ecf8078bf531 415 Write_Data( (Word0 >> 16) & 0xFF );
andrewcrussell 1:ecf8078bf531 416 Write_Data( (Word0 >> 8) & 0xFF );
andrewcrussell 1:ecf8078bf531 417 Write_Data( (Word0 ) & 0xFF );
andrewcrussell 1:ecf8078bf531 418 }
andrewcrussell 1:ecf8078bf531 419 }
andrewcrussell 1:ecf8078bf531 420 Write_Command(NOP);// this terminates the Write Memory command
andrewcrussell 1:ecf8078bf531 421 }
andrewcrussell 1:ecf8078bf531 422 /*****************************************************************************/
andrewcrussell 1:ecf8078bf531 423 /***************** this is the mini-font version ***************************/
andrewcrussell 1:ecf8078bf531 424 void LCDPutStr(char *pString, int x, int y, int Size, int fColor, int bColor) {
andrewcrussell 1:ecf8078bf531 425 // loop until null-terminator is seen
andrewcrussell 1:ecf8078bf531 426 while (*pString != 0x00) {
andrewcrussell 1:ecf8078bf531 427 // draw the character
andrewcrussell 1:ecf8078bf531 428 LCDPutChar(*pString++, y, x, Size, fColor, bColor);
andrewcrussell 1:ecf8078bf531 429 // advance the y position
andrewcrussell 1:ecf8078bf531 430 if (Size == 0)// small
andrewcrussell 1:ecf8078bf531 431 y = y + 6;
andrewcrussell 1:ecf8078bf531 432 else if (Size == 1) //medium
andrewcrussell 1:ecf8078bf531 433 y = y + 8;
andrewcrussell 1:ecf8078bf531 434 else if (Size == 2) //large
andrewcrussell 1:ecf8078bf531 435 y = y + 16;
andrewcrussell 1:ecf8078bf531 436 else if (Size == 3)
andrewcrussell 1:ecf8078bf531 437 y = y + 24; //large1
andrewcrussell 1:ecf8078bf531 438 if (y > 640) break; //bail out if it exceeds screen width
andrewcrussell 1:ecf8078bf531 439 }
andrewcrussell 1:ecf8078bf531 440 }
andrewcrussell 1:ecf8078bf531 441 /******************************** square button ***********************/
andrewcrussell 1:ecf8078bf531 442 void sqbutton1(unsigned int x0, unsigned int y0, unsigned int fill, unsigned int color) {
andrewcrussell 1:ecf8078bf531 443 unsigned int xmin, xmax, ymin, ymax;
andrewcrussell 1:ecf8078bf531 444 int i;
andrewcrussell 1:ecf8078bf531 445
andrewcrussell 1:ecf8078bf531 446 // check if the rectangle is to be filled
andrewcrussell 1:ecf8078bf531 447 if (fill == TRUE) {
andrewcrussell 1:ecf8078bf531 448 // best way to create a filled rectangle is to define a drawing box
andrewcrussell 1:ecf8078bf531 449 // and loop two pixels at a time
andrewcrussell 1:ecf8078bf531 450 // calculate the min and max for x and y directions
andrewcrussell 1:ecf8078bf531 451 xmin = (x0 <= (x0 + xbutsize1)) ? x0 : (x0 + xbutsize1);
andrewcrussell 1:ecf8078bf531 452 xmax = (x0 > (x0 + xbutsize1)) ? x0 : (x0 + xbutsize1);
andrewcrussell 1:ecf8078bf531 453 ymin = (y0 <= (y0+ybutsize1)) ? y0 : (y0+ybutsize1);
andrewcrussell 1:ecf8078bf531 454 ymax = (y0 > (y0+ybutsize1)) ? y0 : (y0+ybutsize1);
andrewcrussell 1:ecf8078bf531 455 Write_Command(CASET); //SET page address
andrewcrussell 1:ecf8078bf531 456 Write_Data((x0)>>8); //SET start page address=0
andrewcrussell 1:ecf8078bf531 457 Write_Data(x0);
andrewcrussell 1:ecf8078bf531 458 Write_Data((x0 + xbutsize1)>>8); //SET end page address=XMAX
andrewcrussell 1:ecf8078bf531 459 Write_Data (x0 + xbutsize1);
andrewcrussell 1:ecf8078bf531 460 Write_Command(PASET); //SET column address
andrewcrussell 1:ecf8078bf531 461 Write_Data((y0)>>8); //SET start column address=0
andrewcrussell 1:ecf8078bf531 462 Write_Data(y0);
andrewcrussell 1:ecf8078bf531 463 Write_Data((y0+ybutsize1)>>8); //SET end column address=YMAX
andrewcrussell 1:ecf8078bf531 464 Write_Data (y0+ybutsize1);
andrewcrussell 1:ecf8078bf531 465 Write_Command(RAMWR); //ready to now start writing the data
andrewcrussell 1:ecf8078bf531 466 for (i = 0; i < ((((xmax - xmin + 1) * (ymax - ymin + 1))) + 1); i++) {
andrewcrussell 1:ecf8078bf531 467 SendData(color);
andrewcrussell 1:ecf8078bf531 468 }
andrewcrussell 1:ecf8078bf531 469 } else {
andrewcrussell 1:ecf8078bf531 470
andrewcrussell 1:ecf8078bf531 471 LCDSetLine(x0, y0, (x0 + xbutsize1), y0, color);
andrewcrussell 1:ecf8078bf531 472 LCDSetLine(x0, (y0+ybutsize1), (x0 + xbutsize1), (y0+ybutsize1), color);
andrewcrussell 1:ecf8078bf531 473 LCDSetLine(x0, y0, x0, (y0+ybutsize1), color);
andrewcrussell 1:ecf8078bf531 474 LCDSetLine((x0 + xbutsize1), y0, (x0 + xbutsize1), (y0+ybutsize1), color);
andrewcrussell 1:ecf8078bf531 475 }
andrewcrussell 1:ecf8078bf531 476 }
andrewcrussell 1:ecf8078bf531 477
andrewcrussell 1:ecf8078bf531 478 /**************************************** volume slider ******************************************/
andrewcrussell 1:ecf8078bf531 479 void volume_slider(int volume) { //was float
andrewcrussell 1:ecf8078bf531 480 int slider;
andrewcrussell 1:ecf8078bf531 481 int pos;
andrewcrussell 2:67e16df2c89a 482 pos = (volume*450)/222;
andrewcrussell 1:ecf8078bf531 483 slider = ZERO+pos; //((volume/255)*SPAN);
andrewcrussell 1:ecf8078bf531 484 LCDSetRect((ZERO-10),37,(SPAN+ZERO+10),60,1,BLACK); //erase the previous slider button position
andrewcrussell 2:67e16df2c89a 485 LCDSetRect(slider,40,(slider+10),60,1,WHITE);
andrewcrussell 2:67e16df2c89a 486
andrewcrussell 1:ecf8078bf531 487 }
andrewcrussell 1:ecf8078bf531 488 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 489 /***************************** this is the main central button ******************************/
andrewcrussell 1:ecf8078bf531 490 void big_button(void) {
andrewcrussell 1:ecf8078bf531 491 int z;
andrewcrussell 1:ecf8078bf531 492 for (z=117;z<122;z++) {
andrewcrussell 1:ecf8078bf531 493 LCDSetCircle(320,240,z,WHITE);
andrewcrussell 1:ecf8078bf531 494 }
andrewcrussell 1:ecf8078bf531 495 for (z=130;z<133;z++) {
andrewcrussell 1:ecf8078bf531 496 LCDSetCircle(320,240,z,WHITE);
andrewcrussell 1:ecf8078bf531 497 }
andrewcrussell 1:ecf8078bf531 498 }
andrewcrussell 1:ecf8078bf531 499 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 500 void volume_display_window(void) {
andrewcrussell 1:ecf8078bf531 501 LCDSetRect(223,198,418,283,0,WHITE);
andrewcrussell 1:ecf8078bf531 502 }
andrewcrussell 1:ecf8078bf531 503 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 504 void slider_bar(void) {
andrewcrussell 1:ecf8078bf531 505
andrewcrussell 1:ecf8078bf531 506 LCDSetRect(100, 20,560,30,0,WHITE);//slider scale volume bar
andrewcrussell 2:67e16df2c89a 507 LCDPutStr("0ff -82 -65 -48 -30 -12 -6 0 +7 +16",10,100,MEDIUM, WHITE,BLACK);//slider scale
andrewcrussell 1:ecf8078bf531 508
andrewcrussell 1:ecf8078bf531 509 }
andrewcrussell 1:ecf8078bf531 510 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 511 void input_sel_window(void) {
andrewcrussell 1:ecf8078bf531 512 LCDSetRect(180,380,460,460,0,WHITE);// input select window
andrewcrussell 1:ecf8078bf531 513 }
andrewcrussell 1:ecf8078bf531 514 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 515 void input_buttons(void) {
andrewcrussell 2:67e16df2c89a 516
andrewcrussell 1:ecf8078bf531 517 LCDSetCircle(xref2,(1*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 518 FontDrawString("CD",(xref2-75),(righttbutinc-20),WHITE,BLACK,&Calibri28);
andrewcrussell 2:67e16df2c89a 519
andrewcrussell 1:ecf8078bf531 520 LCDSetCircle(xref2,(2*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 521 FontDrawString("Aux2",(xref2-108),((2*righttbutinc)-20),WHITE,BLACK,&Calibri28);
andrewcrussell 2:67e16df2c89a 522
andrewcrussell 1:ecf8078bf531 523 LCDSetCircle(xref2,(3*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 524 FontDrawString("Aux1",(xref2-108),((3*righttbutinc)-20),WHITE,BLACK,&Calibri28);
andrewcrussell 2:67e16df2c89a 525
andrewcrussell 1:ecf8078bf531 526 LCDSetCircle(xref2,(4*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 527 FontDrawString("Recdr",(xref2-122),((4*righttbutinc)-20),WHITE,BLACK,&Calibri28);
andrewcrussell 2:67e16df2c89a 528
andrewcrussell 1:ecf8078bf531 529 LCDSetCircle(xref2,(5*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 530 FontDrawString("Phono",(xref2-132),((5*righttbutinc)-20),WHITE,BLACK,&Calibri28);
andrewcrussell 1:ecf8078bf531 531 }
andrewcrussell 1:ecf8078bf531 532
andrewcrussell 1:ecf8078bf531 533 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 534 void phono_d(int onoff) {
andrewcrussell 1:ecf8078bf531 535 int circinc;
andrewcrussell 1:ecf8078bf531 536 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 537 for (circinc=1;circinc<27;circinc++) {
andrewcrussell 1:ecf8078bf531 538 LCDSetCircle(xref2,(5*righttbutinc),circinc,BLACK);
andrewcrussell 1:ecf8078bf531 539 } //first erase the button
andrewcrussell 1:ecf8078bf531 540
andrewcrussell 1:ecf8078bf531 541 LCDSetCircle(xref2,(5*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 542 } //now draw it in outline = OFF
andrewcrussell 1:ecf8078bf531 543
andrewcrussell 1:ecf8078bf531 544 else {
andrewcrussell 1:ecf8078bf531 545 for (circinc=1;circinc<26;circinc++) { //so onoff must have been TRUE
andrewcrussell 1:ecf8078bf531 546 LCDSetCircle(xref2,(5*righttbutinc),circinc,GREEN); //it on so draw it in GREEN
andrewcrussell 1:ecf8078bf531 547 }
andrewcrussell 1:ecf8078bf531 548 }
andrewcrussell 1:ecf8078bf531 549 }
andrewcrussell 1:ecf8078bf531 550 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 551 void AUX1(int onoff) {
andrewcrussell 1:ecf8078bf531 552 int circinc;
andrewcrussell 1:ecf8078bf531 553 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 554 for (circinc=1;circinc<27;circinc++) {
andrewcrussell 1:ecf8078bf531 555 LCDSetCircle(xref2,(3*righttbutinc),circinc,BLACK);
andrewcrussell 1:ecf8078bf531 556 } //first erase the button
andrewcrussell 1:ecf8078bf531 557
andrewcrussell 1:ecf8078bf531 558 LCDSetCircle(xref2,(3*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 559 } //now draw it in outline = OFF
andrewcrussell 1:ecf8078bf531 560
andrewcrussell 1:ecf8078bf531 561 else {
andrewcrussell 1:ecf8078bf531 562 for (circinc=1;circinc<26;circinc++) { //so onoff must have been TRUE
andrewcrussell 1:ecf8078bf531 563 LCDSetCircle(xref2,(3*righttbutinc),circinc,GREEN); //it on so draw it in GREEN
andrewcrussell 1:ecf8078bf531 564 }
andrewcrussell 1:ecf8078bf531 565 }
andrewcrussell 1:ecf8078bf531 566 }
andrewcrussell 1:ecf8078bf531 567 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 568 void AUX2(int onoff) {
andrewcrussell 1:ecf8078bf531 569 int circinc;
andrewcrussell 1:ecf8078bf531 570 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 571 for (circinc=1;circinc<27;circinc++) {
andrewcrussell 1:ecf8078bf531 572 LCDSetCircle(xref2,(2*righttbutinc),circinc,BLACK);
andrewcrussell 1:ecf8078bf531 573 } //first erase the button
andrewcrussell 1:ecf8078bf531 574
andrewcrussell 1:ecf8078bf531 575 LCDSetCircle(xref2,(2*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 576 } //now draw it in outline = OFF
andrewcrussell 1:ecf8078bf531 577
andrewcrussell 1:ecf8078bf531 578 else {
andrewcrussell 1:ecf8078bf531 579 for (circinc=1;circinc<26;circinc++) { //so onoff must have been TRUE
andrewcrussell 1:ecf8078bf531 580 LCDSetCircle(xref2,(2*righttbutinc),circinc,GREEN); //it on so draw it in GREEN
andrewcrussell 1:ecf8078bf531 581 }
andrewcrussell 1:ecf8078bf531 582 }
andrewcrussell 1:ecf8078bf531 583 }
andrewcrussell 1:ecf8078bf531 584 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 585 void CD_d(int onoff) {
andrewcrussell 1:ecf8078bf531 586 int circinc;
andrewcrussell 1:ecf8078bf531 587 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 588 for (circinc=1;circinc<27;circinc++) {
andrewcrussell 1:ecf8078bf531 589 LCDSetCircle(xref2,(1*righttbutinc),circinc,BLACK);
andrewcrussell 1:ecf8078bf531 590 } //first erase the button
andrewcrussell 1:ecf8078bf531 591
andrewcrussell 1:ecf8078bf531 592 LCDSetCircle(xref2,(1*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 593 } //now draw it in outline = OFF
andrewcrussell 1:ecf8078bf531 594
andrewcrussell 1:ecf8078bf531 595 else {
andrewcrussell 1:ecf8078bf531 596 for (circinc=1;circinc<26;circinc++) { //so onoff must have been TRUE
andrewcrussell 1:ecf8078bf531 597 LCDSetCircle(xref2,(1*righttbutinc),circinc,GREEN); //it on so draw it in GREEN
andrewcrussell 1:ecf8078bf531 598 }
andrewcrussell 1:ecf8078bf531 599 }
andrewcrussell 1:ecf8078bf531 600 }
andrewcrussell 1:ecf8078bf531 601 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 602 void Recorder_d(int onoff) {
andrewcrussell 1:ecf8078bf531 603 int circinc;
andrewcrussell 1:ecf8078bf531 604 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 605 for (circinc=1;circinc<27;circinc++) {
andrewcrussell 1:ecf8078bf531 606 LCDSetCircle(xref2,(4*righttbutinc),circinc,BLACK);
andrewcrussell 1:ecf8078bf531 607 } //first erase the button
andrewcrussell 1:ecf8078bf531 608
andrewcrussell 1:ecf8078bf531 609 LCDSetCircle(xref2,(4*righttbutinc),25,WHITE);
andrewcrussell 1:ecf8078bf531 610 } //now draw it in outline = OFF
andrewcrussell 1:ecf8078bf531 611
andrewcrussell 1:ecf8078bf531 612 else {
andrewcrussell 1:ecf8078bf531 613 for (circinc=1;circinc<26;circinc++) { //so onoff must have been TRUE
andrewcrussell 1:ecf8078bf531 614 LCDSetCircle(xref2,(4*righttbutinc),circinc,GREEN); //it on so draw it in GREEN
andrewcrussell 1:ecf8078bf531 615 }
andrewcrussell 1:ecf8078bf531 616 }
andrewcrussell 1:ecf8078bf531 617 }
andrewcrussell 1:ecf8078bf531 618
andrewcrussell 1:ecf8078bf531 619 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 620 void Control_buttons(void) {
andrewcrussell 2:67e16df2c89a 621
andrewcrussell 2:67e16df2c89a 622 sqbutton1(xref1,80,0,WHITE); //mute
andrewcrussell 2:67e16df2c89a 623 FontDrawString("Mute",82,87,WHITE,BLACK,&Calibri28);
andrewcrussell 2:67e16df2c89a 624
andrewcrussell 2:67e16df2c89a 625 sqbutton1(xref1, 196,0,WHITE); //Rec
andrewcrussell 2:67e16df2c89a 626 FontDrawString("Rec",82,197,WHITE,BLACK,&Calibri28); //gap is 66
andrewcrussell 2:67e16df2c89a 627
andrewcrussell 2:67e16df2c89a 628 //sqbutton1(xref1,202,0,WHITE); //stdby
andrewcrussell 2:67e16df2c89a 629 //FontDrawString("Stdby",82,203,WHITE,BLACK,&Calibri28);
andrewcrussell 2:67e16df2c89a 630
andrewcrussell 2:67e16df2c89a 631 sqbutton1(xref1, 312,0,WHITE);//power amp
andrewcrussell 2:67e16df2c89a 632 FontDrawString("Amp",82,313,WHITE,BLACK,&Calibri28);
andrewcrussell 2:67e16df2c89a 633
andrewcrussell 1:ecf8078bf531 634 //sqbutton1(xref1,400,0,RED); //this is the IR indicator
andrewcrussell 1:ecf8078bf531 635 //FontDrawString("IR",82,400,WHITE,BLACK,&Calibri28);
andrewcrussell 1:ecf8078bf531 636
andrewcrussell 1:ecf8078bf531 637 }
andrewcrussell 1:ecf8078bf531 638 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 639 void mute(unsigned int onoff) { //this is the bottom button
andrewcrussell 1:ecf8078bf531 640 if (onoff==0) {
andrewcrussell 2:67e16df2c89a 641 sqbutton1(xref1,80,1,BLACK); //first erase the button
andrewcrussell 2:67e16df2c89a 642 sqbutton1(xref1,80,0,WHITE);
andrewcrussell 1:ecf8078bf531 643 } //now redraw it
andrewcrussell 1:ecf8078bf531 644 else {
andrewcrussell 2:67e16df2c89a 645 sqbutton1(16,80,1,WHITE);
andrewcrussell 1:ecf8078bf531 646 }
andrewcrussell 1:ecf8078bf531 647 }
andrewcrussell 1:ecf8078bf531 648 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 649 void record(unsigned int onoff) { //this is the second from bottom button
andrewcrussell 1:ecf8078bf531 650 if (onoff==0) {
andrewcrussell 2:67e16df2c89a 651 sqbutton1(xref1,196,1,BLACK); //first erase the button
andrewcrussell 2:67e16df2c89a 652 sqbutton1(16, 196,0,WHITE);
andrewcrussell 1:ecf8078bf531 653 } //now redraw it
andrewcrussell 1:ecf8078bf531 654 else {
andrewcrussell 2:67e16df2c89a 655 sqbutton1(16,196,1,WHITE);
andrewcrussell 1:ecf8078bf531 656 }
andrewcrussell 1:ecf8078bf531 657 }
andrewcrussell 1:ecf8078bf531 658 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 659 void stdby(unsigned int onoff) { //this is the 3rd from bottom button
andrewcrussell 1:ecf8078bf531 660 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 661 sqbutton1(xref1,202,1,BLACK); //first erase the button
andrewcrussell 1:ecf8078bf531 662 sqbutton1(xref1, 202,0,WHITE);
andrewcrussell 1:ecf8078bf531 663 } //now redraw it
andrewcrussell 1:ecf8078bf531 664 else {
andrewcrussell 1:ecf8078bf531 665 sqbutton1(xref1,202,1,WHITE);
andrewcrussell 1:ecf8078bf531 666 }
andrewcrussell 1:ecf8078bf531 667 }
andrewcrussell 1:ecf8078bf531 668 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 669 void pwramp(unsigned int onoff) { //this is the top lefthand side button
andrewcrussell 1:ecf8078bf531 670 if (onoff==0) {
andrewcrussell 2:67e16df2c89a 671 sqbutton1(xref1, 312,1,BLACK); //first erase the button
andrewcrussell 2:67e16df2c89a 672 sqbutton1(xref1,312,0,WHITE);
andrewcrussell 1:ecf8078bf531 673 } //now redraw it
andrewcrussell 1:ecf8078bf531 674 else {
andrewcrussell 2:67e16df2c89a 675 sqbutton1(xref1, 312,1,WHITE);
andrewcrussell 1:ecf8078bf531 676 }
andrewcrussell 1:ecf8078bf531 677 }
andrewcrussell 1:ecf8078bf531 678 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 679 void infra(unsigned int onoff) { //this is the top lefthand side button
andrewcrussell 1:ecf8078bf531 680 if (onoff==0) {
andrewcrussell 1:ecf8078bf531 681 sqbutton1(xref1, 400,1,BLACK); //first erase the button
andrewcrussell 1:ecf8078bf531 682 sqbutton1(xref1,400,0,RED);
andrewcrussell 1:ecf8078bf531 683 } //now redraw it
andrewcrussell 1:ecf8078bf531 684 else {
andrewcrussell 1:ecf8078bf531 685 sqbutton1(xref1, 400,1,RED);
andrewcrussell 1:ecf8078bf531 686 }
andrewcrussell 1:ecf8078bf531 687 }
andrewcrussell 1:ecf8078bf531 688 /*************************************************************************************************/
andrewcrussell 1:ecf8078bf531 689 void trigcircle (int xtc, int ytc, int radius, int color) {
andrewcrussell 2:67e16df2c89a 690
andrewcrussell 1:ecf8078bf531 691 double circ;
andrewcrussell 1:ecf8078bf531 692 double cosnum;
andrewcrussell 1:ecf8078bf531 693 double sinum;
andrewcrussell 2:67e16df2c89a 694 for (circ=0;circ<=volume;circ++) {
andrewcrussell 1:ecf8078bf531 695 sinum=sin(circ)*radius;
andrewcrussell 2:67e16df2c89a 696 cosnum=cos(circ)*radius;
andrewcrussell 2:67e16df2c89a 697 LCDSetLine(xtc,ytc,(sinum+xtc),(cosnum+ytc),color);
andrewcrussell 2:67e16df2c89a 698 }
andrewcrussell 1:ecf8078bf531 699 }
andrewcrussell 1:ecf8078bf531 700
andrewcrussell 1:ecf8078bf531 701 /**************************************************************************************/
andrewcrussell 1:ecf8078bf531 702
andrewcrussell 2:67e16df2c89a 703 void clear_input_select(void) {
andrewcrussell 1:ecf8078bf531 704
andrewcrussell 2:67e16df2c89a 705 int circinc;
andrewcrussell 2:67e16df2c89a 706 for (circinc=1;circinc<24;circinc++) {
andrewcrussell 1:ecf8078bf531 707
andrewcrussell 2:67e16df2c89a 708 LCDSetCircle(xref2,(5*righttbutinc),circinc,BLACK); //phono
andrewcrussell 2:67e16df2c89a 709 LCDSetCircle(xref2,(3*righttbutinc),circinc,BLACK); //aux1
andrewcrussell 2:67e16df2c89a 710 LCDSetCircle(xref2,(2*righttbutinc),circinc,BLACK); //aux2
andrewcrussell 2:67e16df2c89a 711 LCDSetCircle(xref2,(1*righttbutinc),circinc,BLACK); //CD
andrewcrussell 2:67e16df2c89a 712 LCDSetCircle(xref2,(4*righttbutinc),circinc,BLACK); //recorder
andrewcrussell 2:67e16df2c89a 713 }
andrewcrussell 2:67e16df2c89a 714 }