summaryrefslogtreecommitdiff
path: root/main.c
blob: 44bbb2df996bac1de20b7d278eeb48fc856f02c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#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;
  }
}