forked from krihal/KK2
/
kk2.cpp
executable file
·73 lines (56 loc) · 1.06 KB
/
kk2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <stdio.h>
#include <stdlib.h>
#include <KK2.h>
#include <lcd/KK2LCD.h>
#include <wiring/wiring.h>
#if KKVER == KK21
#include <MPU6050/MPU6050.h>
#endif
#define LED_PIN PB3
int main()
{
int i, last_led_update = 0;
initWiring();
st7565Init(Font5x7);
st7565ClearScreen();
st7565SetBrightness(12);
st7565DrawString(1, 5, "Test");
for(i = 0; i < 100; i++)
{
st7565DrawPixel(1+i,14);
}
st7565Refresh();
#if KKVER == 21
Fastwire::setup(100, true);
MPU6050 mpu;
mpu.initialize();
#endif
DDRB &= _BV(LED_PIN); // Set pin 3 of port B to output (LED pin)
for(;;)
{
char buff[512];
if(millis() - last_led_update > 1000)
{
PORTB ^= _BV(LED_PIN);
last_led_update = millis();
}
st7565ClearScreen();
#if KKVER == 21
if(mpu.testConnection())
{
st7565DrawString(1,20, "Connected");
}
else
{
st7565DrawString(1,20, "Not connected");
}
sprintf(buff, "acc_x = %d\n", mpu.getAccelerationX());
st7565DrawString(1,30, buff);
#else
st7565DrawString(1,20, "No ACC available");
#endif
st7565Refresh();
delay(50);
}
return 0;
}