int main(void){ int i; Output_Init(); RIT128x96x4_ClearImage(); RIT128x96x4_Line(0,0,50,50,15); RIT128x96x4_ShowImage(); while(1); //printf("hi\n"); //mainTestInterrupt(); // SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // RIT128x96x4Init(1000000); //// RIT128x96x4_Logo(60); // place in middle // RIT128x96x4_BMP(0, 60, ECE); // Delay(50000000); // delay 3 sec at 50 MHz // RIT128x96x4Clear(); // for(i=90; i>5; i=i-2){ // RIT128x96x4_BMP(i, 80, Horse); // Delay(1000000); // delay 0.3 sec at 50 MHz // } // Delay(1000000000); // delay 60 sec at 50 MHz // RIT128x96x4DisplayOff(); // screen saver // while(1){}; }
void BufferDraw(){ int i = 0; unsigned char* data = 0; char buttons = 0; int oldCorrects = corrects; data = receiveData(); if(data!=0) buttons = data[0]&0x0F; RIT128x96x4_Line(0, 70, 128, 70, 5); for(i = 0; i < BUFFER_SIZE; i++){ if(buffer_y[i]>0 && buffer_y[i] <= 70){ drawCircle(32*buffer_col[i]-16, buffer_y[i], width/8); buffer_y[i]+=4; } if(buffer_y[i] >= 70 && buffer_y[i] < 108){ drawCircle(32*buffer_col[i]-16, buffer_y[i], width/8); buffer_y[i]+=2; if(buttons == buffer_col[i] && buttons < 3) corrects++; else if(buffer_col[i]==3 && buttons==4) corrects++; else if(buffer_col[i]==4 && buttons==8) corrects++; } else if(buffer_y[i] >= 108){ buffer_y[i]=0; } } if(oldCorrects==corrects && buttons > 0) errors++; }
void analogClockDraw(){ volatile unsigned long delay; volatile unsigned long elapsed = 0; int x_s, y_s, x_m, y_m, x_h, y_h; DisableInterrupts(); // disable SysTick during setup NVIC_ST_CTRL_R = 0; // disable SysTick during setup NVIC_ST_RELOAD_R = NVIC_ST_RELOAD_M; // maximum reload value NVIC_ST_CURRENT_R = 0; // any write to current clears it // enable SysTick with core clock NVIC_ST_CTRL_R = NVIC_ST_CTRL_ENABLE+NVIC_ST_CTRL_CLK_SRC; delay = NVIC_ST_CURRENT_R ; x_s = (int)(coslut[seconds]*secondRadius + 64); y_s = (int)(sinlut[seconds]*secondRadius + 48); x_m = (int)(coslut[minutes]*miniteRadius + 64); y_m = (int)(sinlut[minutes]*miniteRadius + 48); x_h = (int)(coslut[hours*5 + minutes/12]*hourRadius + 64); y_h = (int)(sinlut[hours*5 + minutes/12]*hourRadius + 48); RIT128x96x4_ClearImage(); drawCircle(64, 48, 45); //draws clock hands RIT128x96x4_Line(64, 48, x_s, y_s, color); RIT128x96x4_Line(64, 48, x_m, y_m, color); RIT128x96x4_Line(64, 48, x_h, y_h, color); RIT128x96x4_ShowImage(); RIT128x96x4StringDraw((hours24>=12)?"PM":"AM", 110, 80, color); RIT128x96x4StringDraw("Alarm", 0, 76, color); RIT128x96x4StringDraw((alarmActive)?"On":"Off", 0, 85, color); RIT128x96x4StringDraw("12", 58, 5, color); RIT128x96x4StringDraw("3", 100, 48, color); RIT128x96x4StringDraw("9", 23, 48, color); RIT128x96x4StringDraw("6", 62, 80, color); elapsed = 1; elapsed = NVIC_ST_CURRENT_R - delay; delay = 0; EnableInterrupts(); }
void RIT128x96x4_DrawAnalogClock(void) { prevXVal = 39; prevYVal = 57; hourPrevXVal = 39; hourPrevYVal = 57; RIT128x96x4_BMP(0, 0, clock2); RIT128x96x4_Line(0, 15, 128,15, 15); RIT128x96x4_ShowImage(); }
//draws circle with radius r centered at (x,y) void drawCircle(int x, int y, int r) { int i; int x_1 = r*coslut[0]+x; int y_1 = r*sinlut[0]+y; for(i = 1; i < 61; i++){ int x_2 = r*coslut[i%60]+x; int y_2 = r*sinlut[i%60]+y; RIT128x96x4_Line(x_1, y_1, x_2, y_2, color); x_1 = x_2; y_1 = y_2; } }
void analogClockTick(unsigned long seconds){ unsigned long minutes = seconds/60; int cosIndex = (int) minutes%60; int sinIndex = (cosIndex+15)%60; int hourCosIndex = (minutes/12)%60; int hourSinIndex = (hourCosIndex+15)%60; int xVal = 38 + ((((int) waveElement[cosIndex])*(21))/100); int yVal = 56 + ((((int) waveElement[sinIndex])*(21))/100); int hourXVal = 38 + ((((int) waveElement[hourCosIndex])*(12))/100); int hourYVal = 56 + ((((int) waveElement[hourSinIndex])*(12))/100); RIT128x96x4_Line(38, 56, prevXVal,prevYVal, 0); RIT128x96x4_Line(38, 56, hourPrevXVal,hourPrevYVal, 0); //RIT128x96x4_BMP(0, 0, clock2); RIT128x96x4_Line(38, 56, xVal,yVal, 15); RIT128x96x4_Line(38, 56, hourXVal,hourYVal, 15); prevXVal = xVal; //we do this so that the clock doesn't flash on every tick update prevYVal = yVal; hourPrevXVal = hourXVal; hourPrevYVal = hourYVal; RIT128x96x4_DrawString("$$", 112, 82, 0); if (seconds < 43200) { RIT128x96x4_DrawString("AM", 112, 82, 15); } else { RIT128x96x4_DrawString("PM", 112, 82, 15); } }
int main(void){ int color = 10; SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); RIT128x96x4Init(1000000); RIT128x96x4_ClearImage(); RIT128x96x4_WhiteImage(); RIT128x96x4_ShowImage(); SysCtlDelay(8000000); // delay ~2 sec at 12 MHz RIT128x96x4_ClearImage(); RIT128x96x4_ShowImage(); SysCtlDelay(4000000); //vertical line, delay, clear RIT128x96x4_Line(64,0,64,90,color); RIT128x96x4_ShowImage(); SysCtlDelay(8000000); // delay ~2 sec at 12 MHz RIT128x96x4_ClearImage(); RIT128x96x4_ShowImage(); SysCtlDelay(4000000); //horizontal line, delay, clear RIT128x96x4_Line(0,46,128,46,color); RIT128x96x4_ShowImage(); SysCtlDelay(8000000); RIT128x96x4_ClearImage(); RIT128x96x4_ShowImage(); SysCtlDelay(4000000); //cross, delay, clear RIT128x96x4_Line(64,0,64,90,color); RIT128x96x4_Line(0,46,128,46,color); RIT128x96x4_ShowImage(); SysCtlDelay(8000000); RIT128x96x4_ClearImage(); RIT128x96x4_ShowImage(); SysCtlDelay(4000000); RIT128x96x4_Line(0,0,120,90,color); RIT128x96x4_ShowImage(); SysCtlDelay(8000000); RIT128x96x4_ClearImage(); RIT128x96x4_ShowImage(); SysCtlDelay(4000000); RIT128x96x4_Line(120,90,0,0,color); RIT128x96x4_ShowImage(); SysCtlDelay(8000000); RIT128x96x4_ClearImage(); RIT128x96x4_ShowImage(); SysCtlDelay(4000000); RIT128x96x4_Line(64,46,110,5,color); RIT128x96x4_ShowImage(); SysCtlDelay(8000000); RIT128x96x4_ClearImage(); RIT128x96x4_ShowImage(); SysCtlDelay(4000000); RIT128x96x4_Line(110,5,64,46,color); RIT128x96x4_ShowImage(); SysCtlDelay(8000000); RIT128x96x4_ClearImage(); RIT128x96x4_ShowImage(); SysCtlDelay(4000000); RIT128x96x4_Line(60,0,120,90,color); RIT128x96x4_ShowImage(); SysCtlDelay(8000000); RIT128x96x4_ClearImage(); RIT128x96x4_ShowImage(); SysCtlDelay(4000000); for( ; ; ) {} }