91 lines
1.5 KiB
C
91 lines
1.5 KiB
C
#include <stdio.h>
|
|
#include <avr/io.h>
|
|
#include <util/delay.h>
|
|
#include <avr/interrupt.h>
|
|
|
|
#include "pins.h"
|
|
#include "menu.h"
|
|
#include "software_pwm.h"
|
|
#include "analog_read.h"
|
|
|
|
/** light projector controller. How it'll work:
|
|
* Potentiometer with a voltage dividor to send 0-5v into analog input.
|
|
* Button [mode] to change modes.
|
|
* Button [select] to select values within mode.
|
|
*
|
|
* [modes] (press mode button to switch, select button to select children options to ajust with potentiometer):
|
|
* RGB shift
|
|
* rgb hue speed
|
|
*
|
|
* Just white
|
|
*
|
|
* Control RGBW
|
|
* R
|
|
* G
|
|
* B
|
|
* W
|
|
*
|
|
* Chagne motor speed
|
|
* motor speed
|
|
*
|
|
* OFF
|
|
*
|
|
*
|
|
**/
|
|
|
|
|
|
|
|
|
|
void test_adc() {
|
|
DDRA = 0xff;
|
|
for(;;) {
|
|
|
|
int shift_amount = (8 * ((float)analog_read_8bit() / UINT8_MAX));
|
|
|
|
if(shift_amount < 0) {
|
|
PORTA = 0;
|
|
continue;
|
|
}
|
|
else if(shift_amount >= 8) {
|
|
PORTA = 0xff;
|
|
continue;
|
|
}
|
|
|
|
PORTA = (1 << shift_amount);
|
|
}
|
|
}
|
|
|
|
void test_softpwm() {
|
|
/**
|
|
softpwm_set(0, 0);
|
|
softpwm_set(1, 31);
|
|
softpwm_set(2, 31 * 2);
|
|
softpwm_set(3, 31 * 3);
|
|
softpwm_set(4, 31 * 4);
|
|
softpwm_set(5, 31 * 5);
|
|
softpwm_set(6, 31 * 6);
|
|
softpwm_set(7, 255);
|
|
**/
|
|
for(;;);
|
|
}
|
|
|
|
int main() {
|
|
//init_adc();
|
|
//test_adc();
|
|
init_softpwm();
|
|
test_softpwm();
|
|
|
|
int mode = 0;
|
|
//int submode = 0;
|
|
switch(mode) {
|
|
case RAINBOW:
|
|
break;
|
|
case WHITE:
|
|
break;
|
|
case RGBW_MANUAL:
|
|
break;
|
|
case MOTOR_SPEED:
|
|
break;
|
|
}
|
|
}
|