Further implement modes

This commit is contained in:
2022-10-22 00:16:33 +02:00
parent 6104ccd08a
commit d85591c41e
12 changed files with 462 additions and 109 deletions

36
include/animation.h Normal file
View File

@@ -0,0 +1,36 @@
#ifndef _ANIMATION_H_
#define _ANIMATION_H_
#include <stdint.h>
enum animation_state {
ANI_RED,
ANI_GREEN,
ANI_BLUE,
ANI_RAINBOW,
ANI_FLASH_WHITE,
};
struct animation {
enum animation_state state;
uint32_t step;
uint32_t last_tick;
uint32_t next_interval;
};
/**
* @brief Reset aniamtion to start conditions
*
* @param ani Animation
*/
void animation_reset(struct animation *ani);
/**
* @brief Poll animation
*
* @param ani Animation
* @param dmx_universe Target universe to play animation into. Must be big enough
*/
void animation_process(struct animation *ani, uint8_t *dmx_universe);
#endif /* _ANIMATION_H_ */

13
include/gamma.h Normal file
View File

@@ -0,0 +1,13 @@
#ifndef _GAMMA_H_
#define _GAMMA_H_
#include <stdint.h>
extern const uint8_t global_gamma_correction_table[256];
static inline uint8_t gamma_corr(uint8_t raw)
{
return global_gamma_correction_table[raw];
}
#endif /* _GAMMA_H_ */

View File

@@ -9,6 +9,6 @@ void i2c_reset(void);
int i2c_write(uint8_t i2c_addr, const uint8_t *data, uint8_t len);
int i2c_read(uint8_t i2c_addr, uint8_t command, uint8_t *data, uint8_t len);
int i2c_read(uint8_t i2c_addr, uint8_t command, uint8_t *data, uint8_t len);
#endif /* _I2C_H_ */

28
include/pca9555.h Normal file
View File

@@ -0,0 +1,28 @@
#ifndef _PCA9555_H_
#define _PCA9555_H_
#include <stdint.h>
#define PCA9555_I2C_ADDR (0x40)
#define PCA9555_REG_IN_PORT0 (0x0)
#define PCA9555_REG_IN_PORT1 (0x1)
#define PCA9555_REG_OUT_PORT0 (0x2)
#define PCA9555_REG_OUT_PORT1 (0x3)
#define PCA9555_REG_POLARITY0 (0x4)
#define PCA9555_REG_POLARITY1 (0x5)
#define PCA9555_REG_CONFIG0 (0x6)
#define PCA9555_REG_CONFIG1 (0x7)
/**
* @brief Init I2C and port expander
*/
void port_expander_init(void);
uint8_t port_expander_get_buttons(void);
void port_expander_set_leds(uint8_t leds);
uint8_t port_expander_get_leds(void);
void port_expander_set_single_led(uint8_t pos, uint8_t val);
#endif /* _PCA9555_H */