void plot(){ unsigned int sample1,sample2,i=0; buttonsPressed=0; Dogs102x6_init(); Dogs102x6_backlightInit(); Dogs102x6_setBacklight(11); Dogs102x6_setContrast(11); Dogs102x6_clearScreen(); Dogs102x6_stringDraw(7, 0, "*S2=Esc*", DOGS102x6_DRAW_NORMAL); while(1) { if(buttonsPressed){ buttonsPressed=0; lcd_init(); //initialise grlib break; } if(i == 101) { Dogs102x6_clearScreen(); Dogs102x6_stringDraw(7, 0, "*S2=Esc*",DOGS102x6_DRAW_NORMAL); i = 0; } ADC12CTL0 |= ADC12SC + ADC12ENC; // Start sampling/conversion while (ADC12CTL1 & ADC12BUSY) __no_operation(); sample1 = ADC12MEM0 & 0x0FFF; __delay_cycles(1000000); ADC12CTL0 |= ADC12SC + ADC12ENC; // Start sampling/conversion while (ADC12CTL1 & ADC12BUSY) __no_operation(); sample2 = ADC12MEM0 & 0x0FFF; Dogs102x6_lineDraw(i,56-sample1/86,i+1,56-sample2/86,0); /*if(buttonsPressed && BUTTON_S1) { buttonsPressed = 0; while(!(buttonsPressed && BUTTON_S1)); buttonsPressed = 0; }*/ ++ i; } }
uint8_t Menu_active(char **menuText, uint8_t numItems) { uint8_t i; uint8_t position = 0; uint8_t lastPosition = 9; if (numItems > 7){ // Screen is 8 lines tall = 1 // title line + 7 items max numItems = 7; } Dogs102x6_clearImage(numItems + 1, 102, 0, 0); Dogs102x6_stringDraw(0, 0, menuText[0], DOGS102x6_DRAW_NORMAL); // Print the title buttonsPressed = 0; while (!buttonsPressed) // Menu active until selection // is made { position = Wheel_getPosition(); if (position > numItems){ position = numItems; } else if (position == 0){ position = 1; } if (position != lastPosition) // Update position if it is // changed { for (i = 1; i < numItems + 1; i++) // Display menu items { if (i != position){ Dogs102x6_stringDraw(i, 0, menuText[i], DOGS102x6_DRAW_NORMAL); } else { // Highlight item at current position Dogs102x6_stringDraw(i, 0, menuText[i], DOGS102x6_DRAW_INVERT); } } lastPosition = position; } } return position; }
void Dogs_print_int(int column, int row,int n){ char s[10]; snprintf(s,10,"%d",n); Dogs102x6_stringDraw(column, row, s, 0x00); }
//Plots adc values on pin 6.6 on LCD void plot(){ unsigned int sample1,sample2,i=0; Buttons_init(BUTTON_S2); Buttons_interruptEnable(BUTTON_S2); Buttons_init(BUTTON_S1); Buttons_interruptEnable(BUTTON_S1); buttonsPressed = 0; Dogs102x6_init(); Dogs102x6_backlightInit(); Dogs102x6_setBacklight(11); Dogs102x6_setContrast(11); Dogs102x6_clearScreen(); int buffer[104]; int j; for(j=0; j<102; j++){ buffer[j] = 0; } Dogs102x6_stringDraw(7, 0, "S2=Esc S1=P/R", DOGS102x6_DRAW_NORMAL); while(1) { if(buttonsPressed & BUTTON_S2){ _delay_ms(200); buttonsPressed=0; lcd_init(); //initialise grlib break; } if(i == 101) { Dogs102x6_clearScreen(); int j; for(j=0; j<102; j++){ buffer[j] = 0; } Dogs102x6_stringDraw(7, 0, "S2=Esc S1=P/R",DOGS102x6_DRAW_NORMAL); i = 0; } ADC12CTL0 |= ADC12SC + ADC12ENC; // Start sampling/conversion while (ADC12CTL1 & ADC12BUSY) __no_operation(); sample1 = ADC12MEM0 & 0x0FFF; buffer[i]=sample1; __delay_cycles(1000000); ADC12CTL0 |= ADC12SC + ADC12ENC; // Start sampling/conversion while (ADC12CTL1 & ADC12BUSY) __no_operation(); sample2 = ADC12MEM0 & 0x0FFF; buffer[i+1]=sample2; Dogs102x6_lineDraw(i,56-sample1/86,i+1,56-sample2/86,0); //Pause the screen if(buttonsPressed & BUTTON_S1){ _delay_ms(200); buttonsPressed = 0; while(!(buttonsPressed & BUTTON_S1)){ Dogs102x6_clearScreen(); int j; for(j=0; j<104; j++){ Dogs102x6_lineDraw(j,56-buffer[j]/86,j+1,56-buffer[j+1]/86,0); } Wheel_init(); int pos = Wheel_getValue(); Dogs102x6_lineDraw(0,(int)(pos*48)/4096+8,104,(int)(pos*48)/4096+8,0); char c1[10], c2[10]; int reverse_adc = 86*(48 - (pos*48)/4096); snprintf(c1, 10,"%d", reverse_adc); Dogs102x6_stringDraw(56, 0, c1, DOGS102x6_DRAW_NORMAL); int voltage = reverse_adc*3.7/4096.0 * 1000; //Voltage in mV snprintf(c2, 10,"%d", voltage); Dogs102x6_stringDraw(0, 0, c2, DOGS102x6_DRAW_NORMAL); Dogs102x6_stringDraw(0, 28, "mV", DOGS102x6_DRAW_NORMAL); _delay_ms(500); } _delay_ms(200); buttonsPressed = 0; Dogs102x6_clearScreen(); adc_init(); //init required to use 6.6 } ++ i; } }