This repository has been archived on 2025-01-09. You can view files and clone it, but cannot push or open issues or pull requests.
pig-feeder/lib/tm1637/tm1637.h

65 lines
947 B
C++

//
// Created by kerya on 12.06.2022.
//
#include <avr/io.h>
#ifndef TM1637_H
#define TM1637_H
#ifndef TM1637_PORT
#error "TM1637_PORT is not defined"
#endif
#ifndef TM1637_PIN
#error "TM1637_PIN is not defined"
#endif
#ifndef TM1637_REGISTER
#error "TM1637_REGISTER is not defined"
#endif
#ifndef TM1637_CLK
#error "TM1637_CLK is not defined"
#endif
#ifndef TM1637_DIO
#error "TM1637_DIO is not defined"
#endif
#define TM1637_I2C_COMM1 0x40
#define TM1637_I2C_COMM2 0xC0
#define TM1637_I2C_COMM3 0x80
#define SEG_DOT 0b10000000
class TM1637 {
private:
uint8_t data[4];
uint8_t brightness;
void start();
void stop();
uint8_t send(uint8_t d);
void delay();
public:
void clear();
void redraw();
TM1637();
void setSegment(uint8_t index, uint8_t data);
uint8_t encodeChar(char c);
uint8_t encodeNumber(uint8_t n);
void enable();
void disable();
};
#endif //TM1637_H