Stefan Schuermans commited on 2015-08-24 17:22:33
Showing 3 changed files, with 40 additions and 11 deletions.
... | ... |
@@ -1,15 +1,24 @@ |
1 | 1 |
cmake_minimum_required(VERSION 2.8 ) |
2 | 2 |
|
3 |
+include(generic-gcc-avr.cmake) |
|
4 |
+ |
|
3 | 5 |
project(bulb_mm C ASM) |
4 | 6 |
|
5 | 7 |
set(CMAKE_BUILD_TYPE MinSizeRel) |
6 |
-set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -std=c99) |
|
7 | 8 |
|
9 |
+# Adjust for your ISP |
|
8 | 10 |
set(AVR_MCU attiny2313) |
9 |
-set(AVR_PROGRAMMER avr910) |
|
10 |
-set(AVR_UPLOADTOOL_PORT /dev/ttyUSB0) |
|
11 |
-set(AVR_UPLOADTOOL_OPTIONS -b 115200) |
|
12 | 11 |
|
12 |
+#set(AVR_PROGRAMMER usbtiny) |
|
13 |
+#set(AVR_PROGRAMMER avr910) |
|
14 |
+set(AVR_PROGRAMMER avrisp2) |
|
15 |
+#set(AVR_UPLOADTOOL_PORT /dev/ttyUSB0) |
|
16 |
+#set(AVR_UPLOADTOOL_OPTIONS -b 115200) |
|
17 |
+ |
|
18 |
+set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -std=c99) |
|
19 |
+ |
|
20 |
+include_directories(/usr/avr/include/avr) |
|
21 |
+set_source_files_properties(bulb.asm PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp") |
|
13 | 22 |
|
14 | 23 |
#add_avr_executable(bulb_orig |
15 | 24 |
# bulb.asm) |
... | ... |
@@ -1,12 +1,17 @@ |
1 | 1 |
configure your programmer in CMakeLists.txt |
2 | 2 |
|
3 |
+set(AVR_PROGRAMMER usbtiny) |
|
4 |
+#set(AVR_PROGRAMMER avr910) |
|
5 |
+#set(AVR_UPLOADTOOL_PORT /dev/ttyUSB0) |
|
6 |
+#set(AVR_UPLOADTOOL_OPTIONS -b 115200) |
|
7 |
+ |
|
3 | 8 |
build on Linux |
4 | 9 |
============== |
5 | 10 |
|
6 | 11 |
rm -rf build |
7 | 12 |
mkdir build |
8 | 13 |
cd build |
9 |
-cmake -DCMAKE_TOOLCHAIN_FILE=../generic-gcc-avr.cmake .. |
|
14 |
+cmake .. |
|
10 | 15 |
make |
11 | 16 |
|
12 | 17 |
flashing on Linux |
... | ... |
@@ -59,22 +59,37 @@ void swapBuffers() |
59 | 59 |
displayBufferIndex = ( displayBufferIndex + 1 ) % 2; |
60 | 60 |
} |
61 | 61 |
|
62 |
-void wurm(uint8_t length, uint8_t reverse) |
|
62 |
+void wurm(int8_t length, uint8_t reverse) |
|
63 | 63 |
{ |
64 | 64 |
for (int8_t frontPosition = reverse ? NUM_LEDS : 0; |
65 | 65 |
reverse ? frontPosition >= - length - 1 : frontPosition < NUM_LEDS + length; |
66 | 66 |
reverse ? --frontPosition : ++frontPosition) |
67 | 67 |
{ |
68 |
- for(uint8_t pos = 0; pos < NUM_LEDS; ++pos) |
|
68 |
+ for(int8_t pos = 0; pos < NUM_LEDS; ++pos) |
|
69 | 69 |
{ |
70 |
- int8_t dist = abs(pos - frontPosition); |
|
71 | 70 |
uint8_t value = 0; |
72 |
- if ( ((reverse && pos >= frontPosition) || |
|
73 |
- (!reverse && pos <= frontPosition)) && |
|
74 |
- dist < length) |
|
71 |
+ if (!reverse) |
|
72 |
+ { |
|
73 |
+ if (pos <= frontPosition) |
|
74 |
+ { |
|
75 |
+ int8_t dist = frontPosition - pos; |
|
76 |
+ if (dist < length) |
|
75 | 77 |
{ |
76 | 78 |
value = MAX_TIME / (1 + 4 * dist); |
77 | 79 |
} |
80 |
+ } |
|
81 |
+ } |
|
82 |
+ else |
|
83 |
+ { |
|
84 |
+ if (pos >= frontPosition) |
|
85 |
+ { |
|
86 |
+ int8_t dist = pos - frontPosition; |
|
87 |
+ if (dist < length) |
|
88 |
+ { |
|
89 |
+ value = MAX_TIME / (1 + 4 * dist); |
|
90 |
+ } |
|
91 |
+ } |
|
92 |
+ } |
|
78 | 93 |
LED(pos) = value; |
79 | 94 |
} |
80 | 95 |
swapBuffers(); |
81 | 96 |