summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes1
-rw-r--r--.gitignore31
-rw-r--r--Tacho_screen.atsuobin2560 -> 2560 bytes
-rw-r--r--Tacho_screen.c43
4 files changed, 54 insertions, 21 deletions
diff --git a/.gitattributes b/.gitattributes
index 157cc39..2dd9c86 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -9,6 +9,7 @@
*.fsproj merge=union
*.dbproj merge=union
*.cproj merge=union
+*.c diff=c
diff --git a/.gitignore b/.gitignore
index 714a294..5f1e7e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+@@ -1,227 +1,26 @@
#################
## Eclipse
#################
@@ -224,4 +225,32 @@ pip-log.txt
.lss
.map
.o
-.srec \ No newline at end of file
+.srec
+ No newline at end of file
+# Auto detect text files and perform LF normalization
+* text=auto
+
+# Custom for Visual Studio
+*.cs diff=csharp
+*.sln merge=union
+*.csproj merge=union
+*.vbproj merge=union
+*.fsproj merge=union
+*.dbproj merge=union
+*.cproj merge=union
+*.c diff=c
+
+
+
+# Standard to msysgit
+*.doc diff=astextplain
+*.DOC diff=astextplain
+*.docx diff=astextplain
+*.DOCX diff=astextplain
+*.dot diff=astextplain
+*.DOT diff=astextplain
+*.pdf diff=astextplain
+*.PDF diff=astextplain
+*.rtf diff=astextplain
+*.RTF diff=astextplain
+
diff --git a/Tacho_screen.atsuo b/Tacho_screen.atsuo
index c58da35..1fd7620 100644
--- a/Tacho_screen.atsuo
+++ b/Tacho_screen.atsuo
Binary files differ
diff --git a/Tacho_screen.c b/Tacho_screen.c
index 9b5a138..ea7cf55 100644
--- a/Tacho_screen.c
+++ b/Tacho_screen.c
@@ -8,10 +8,10 @@
#include <util/delay.h>
#include <avr/interrupt.h>
-#define _PRIM PORTC
-#define _SEC PORTD
+#define _PRIM PORTC //Right digit
+#define _SEC PORTD //Left digit
-#define _WHEEL_SIZE 207
+#define _WHEEL_SIZE 207 //In cm
//Define characters (negative)
#define _C1 0b10101111
@@ -27,25 +27,25 @@
#define _C_ 0b11111101
#define _CCLEAR 255
-uint32_t cntr;
-unsigned int speed;
+uint32_t cntr; //counter for Timer
+unsigned int speed; //global var to save the calculated speed in
-ISR(TIMER0_OVF_vect)
+ISR(TIMER0_OVF_vect) //ISR for TIMER0 overflow
{
cntr++;
}
inline void calcSpeed(void)
{
- float tmrSpeed = F_CPU / 256;
- float tmrTime = 1 / tmrSpeed;
- float comTime = tmrTime * cntr;
+ float tmrSpeed = F_CPU / 256; //The timer overflow speed in Hz
+ float tmrTime = 1 / tmrSpeed; //The timer overflow speed in s
+ float comTime = tmrTime * cntr; //calculate the total time
- float mps = (_WHEEL_SIZE / 100) / comTime;
+ float mps = (_WHEEL_SIZE / 100) / comTime; //Convert wheelsize to m and derive by the complete time
- float kmph = mps * 3.6;
+ float kmph = mps * 3.6; //km/h = m/s * 3.6
- speed = (int)kmph;
+ speed = (int)kmph; //cast to int and write into global var speed
}//calcSpeed()
inline void render(int _screen)
@@ -55,7 +55,10 @@ inline void render(int _screen)
int i1, i2;
itoa(_screen, cNr, 10); //convert int to string for rendering
-
+ /*
+ * If _screen is smaller than 10, the cNr contains 1xxxxxxxxxx, but if it is bigger than 10 it looks like this: 10xxxxxxxxxx
+ * So I have to change the digits
+ */
if(_screen < 10)
{
i1 = 0;
@@ -159,24 +162,24 @@ int main(void)
TCCR0 = (1 << CS00); // Prescaler 1
TIMSK = (1<<TOIE0); //Enable Overflowinterrupt
- cntr = 0; //counter for Timer
- DDRC = DDRD = 255; // Output for scrren pins
+ cntr = 0; //init counter for Timer
+ DDRC = DDRD = 255; // Output for screen pins
DDRB |= (1<<PB2);
DDRB &= ~(1<<PB1);
- sei();
+ sei(); //enable interrupts
- render(0);
+ render(0); //init the display
while(1)//main loop
{
- while(PINB & (1 << PB1) && cntr < 30000){} // wait for reed
+ while(PINB & (1 << PB1) && cntr < 30000){} // wait for reedcontact on PB1
TCCR0 = ~(1 << CS00); //disable counter
cli(); //disable interrupts
calcSpeed();
//reset all variables
- cntr = 0;
- TCNT0 = 0;
+ cntr = 0; //Reset counter
+ TCNT0 = 0; //Reset Timer
sei();//enable interrupts
TCCR0 = (1 << CS00); //enable counter