@@ -29,7 +29,25 @@ uint32_t packet_sent=1;
uint32_t packet_receive=1;
char* itoa(int i, char b[]){
char const digit[] = "0123456789";
char* p = b;
if(i<0){
*p++ = '-';
i *= -1;
}
int shifter = i;
do{ //Move to where representation ends
++p;
shifter = shifter/10;
}while(shifter);
*p = '\0';
do{ //Move back, inserting digits as u go
*--p = digit[i%10];
i = i/10;
}while(i);
return b;
static __IO uint32_t TimingDelay;
@@ -77,17 +95,18 @@ int main(void)
uint8_t toggle = 0;
int16_t temp = 0;
int16_t temp = -231;
while(1)
{
temp = SPI_I2S_ReceiveData(SPI2);
ssd1306_DrawString("Temp: ", 1, 40);
//ssd1306_DrawString("Temp: ", 1, 40);
char tempstr[5];
char test = temp + 0x30;
itoa(temp, tempstr);
ssd1306_DrawString("Temp: ", 3, 40);
//char test = temp + 0x30;
//sprintf(tempstr, "%d", test);
//ssd1306_DrawString(tempstr, 1, 70);
ssd1306_DrawString(tempstr, 3, 70);
//ssd1306_block_write();
@@ -100,19 +119,17 @@ int main(void)
// TODO: Grab buttonpresses with interrupts
uint8_t sw_btn = GPIO_ReadInputDataBit(SW_BTN);
uint8_t sw_up = GPIO_ReadInputDataBit(SW_UP);
uint8_t sw_down = GPIO_ReadInputDataBit(SW_DOWN);
uint8_t sw_left = GPIO_ReadInputDataBit(SW_LEFT);
uint8_t sw_right = GPIO_ReadInputDataBit(SW_RIGHT);
//uint8_t sw_up = GPIO_ReadInputDataBit(SW_UP);
//uint8_t sw_down = GPIO_ReadInputDataBit(SW_DOWN);
//uint8_t sw_left = GPIO_ReadInputDataBit(SW_LEFT);
//uint8_t sw_right = GPIO_ReadInputDataBit(SW_RIGHT);
if(!sw_btn) {
GPIO_ToggleBits(LED_STAT);
if(!toggle) {
ssd1306_DrawString("________________", 3, 32);
toggle = ! toggle;
else {
ssd1306_DrawString("----------------", 3, 32);
Status change: