-int delay() {
-
- int a = 0;
- for (int i = 0; i < TIMEOUT; i++)
- a++;
-}
-
-void set_display(bool on, uint8_t degree) {
-
- start_condition();
-
- regw_u32(I2C_DR, 0xF1, 0, OWRITE);
- if(!ack_recv())
- cputs("Can't switch on display!");
- stop_condition();
-
- // reset bus
- regw_u32(I2C_CR1, 0x1, 15, SETBIT);
-
-}
-
-
-void set_segment(int offset, char value, bool dot) {
-
- int (*ack)() = ack_recv; /* Scary function pointer :D */
-
-
- if (offset > 3) {
- cputs("Offset incorrect");
- }
-
- if (dot) {
- value = value | 0x1;
- }
- int start_pos_cmd = 0x03 | (offset & 0x01) << 7 | (offset & 0x2) << 5 ;
-
- start_condition();
- regw_u32(I2C_DR, 0x20, 0, OWRITE);
- if(!ack_recv())
- cputs("Error: initiating write for start segment \n");
-
- stop_condition();
-
- if(!idle())
- cputs("Error: timeout");
-
-
- start_condition();
- regw_u32(I2C_DR, start_pos_cmd, 0, OWRITE);
- if(!ack())
- cputs("Error: Can't set start segment \n");
-
- stop_condition();
- regw_u32(I2C_CR1, 0x1, 15, SETBIT);
-
- tm1637_reset();
-
-// if (value & 0xF0)
-// ack = &ack10_recv;
-
- start_condition();
- regw_u32(I2C_DR, value, 0, OWRITE); // use ack10 if higher
- if(!ack_recv())
- cputs("Error: can't set location\n");
- stop_condition();
-
- regw_u32(I2C_CR1, 0x1, 15, SETBIT);
-
- tm1637_reset();
-}
-
-
-
-void tm1637_start() {
-
-unsigned char display_number[10] = {0xFC, 0x60, 0xDA, 0xF2, 0x66, 0xB6, 0xBE, 0xE0, 0xFE, 0xF6};
-
-
- char love[4] = { 0x1C, 0xFC, 0x7C, 0x9E };
-
- for (int i = 0; i < 4; i++) {
- set_segment(i, love[i], NODOT);
- }
-
- set_display(true, 0);
-
-}
-