6 #ifndef LIBPROPELLER_ELUM_H_
7 #define LIBPROPELLER_ELUM_H_
50 Elum(
int RedPin,
int GreenPin,
int ButtonPin) {
51 Start(RedPin, GreenPin, ButtonPin);
57 void Start(
int RedPin,
int GreenPin,
int ButtonPin) {
58 b_mask = 1 << ButtonPin;
78 return (
INA & b_mask) == 0;
88 if (whichColor ==
RED) {
90 OUTA &= ~(1 << pin_r);
92 OUTA &= ~(1 << pin_g);
99 OUTA &= ~(1 << pin_r);
100 OUTA &= ~(1 << pin_g);
115 void Flash(
int color,
int period_ms,
int flash_ms) {
120 Pwm(pin_r, period_ms, flash_ms);
121 }
else if (color ==
GREEN) {
123 Pwm(pin_g, period_ms, flash_ms);
180 FRQA = (((1000) << 2) * (0x40000000 / (CLKFREQ / 1000))) / 1000;
181 CTRA = (0b00100000 << 23) + pin_r;
182 FRQB = (((10000 + frequency) << 2) * (0x40000000 / (CLKFREQ / 1000))) / 10000;
183 CTRB = (0b00100000 << 23) + pin_g;
193 int Fraction(
int Y,
int X,
int B) {
205 _idx__0000 = (_idx__0000 + -1);
206 }
while (_idx__0000 >= 1);
211 int Pwm(
int Pin,
int Period_ms,
int Flash_ms) {
214 Flash_ms = ((Period_ms / 2) - (Min__(Flash_ms, (Period_ms / 2))));
215 Phsx = Fraction(Flash_ms, Period_ms, 32);
216 Frqx = Fraction(1, ((_clockfreq / 1000) * Period_ms), 32);
219 _clockfreq = CLKFREQ;
226 void Pattern(
int tRed,
int tGreen,
int phsGreen) {
227 PHSB = (0x7FFFFFFF / 100 * phsGreen) << 1;
230 CTRA = (0b00100000 << 23) + pin_r;
231 CTRB = (0b00100000 << 23) + pin_g;
236 static inline int32_t Min__(int32_t
a, int32_t
b) {
237 return a < b ? a :
b;
243 #endif // SRLM_PROPGCC_ELUM_H_