Count up seconds on display

This commit is contained in:
Michael Mandl 2017-02-24 21:48:01 +01:00
parent 86df456b0f
commit f7393f0661
2 changed files with 64 additions and 40 deletions

View file

@ -1,46 +1,27 @@
#define F_CPU 1000000 #include "Hardware.h"
#include "MyLcd.h"
#include <avr/io.h> #include <avr/io.h>
#include <util/delay.h>
#include "LcdShiftReg.h" extern "C" void __cxa_pure_virtual(void)
void setupStatusLed()
{ {
DDRB |= (1 << PB0);
}
void flashStatusLed()
{
PORTB |= (1 << PB0);
_delay_ms(100);
PORTB &= ~(1 << PB0);
} }
int main() int main()
{ {
setupStatusLed(); MyLcd lcd;
delay_ms(40);
lcd.initDisplay();
LcdShiftReg lcdShiftReg; uint16_t counter = 0;
while (true) while (true)
{ {
flashStatusLed(); lcd.clear();
_delay_ms(400); lcd.output(counter++);
lcd.output('s');
lcdShiftReg.set(1); delay_ms(1000);
_delay_ms(100);
lcdShiftReg.set(0);
_delay_ms(400);
lcdShiftReg.set(1 << 1);
_delay_ms(100);
lcdShiftReg.set(0);
_delay_ms(400);
lcdShiftReg.set(1 << 7);
_delay_ms(100);
lcdShiftReg.set(0);
_delay_ms(400);
} }
} }

View file

@ -55,23 +55,47 @@
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures> <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned> <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned> <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.directories.IncludePaths><ListValues><Value>%24(PackRepoDir)\Atmel\ATtiny_DFP\1.2.112\include</Value></ListValues></avrgcc.compiler.directories.IncludePaths> <avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>NDEBUG</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\Atmel\ATtiny_DFP\1.2.112\include</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers> <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum> <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings> <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned> <avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned> <avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcccpp.compiler.directories.IncludePaths><ListValues><Value>%24(PackRepoDir)\Atmel\ATtiny_DFP\1.2.112\include</Value></ListValues></avrgcccpp.compiler.directories.IncludePaths> <avrgcccpp.compiler.symbols.DefSymbols>
<ListValues>
<Value>NDEBUG</Value>
</ListValues>
</avrgcccpp.compiler.symbols.DefSymbols>
<avrgcccpp.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\Atmel\ATtiny_DFP\1.2.112\include</Value>
</ListValues>
</avrgcccpp.compiler.directories.IncludePaths>
<avrgcccpp.compiler.optimization.level>Optimize for size (-Os)</avrgcccpp.compiler.optimization.level>
<avrgcccpp.compiler.optimization.PackStructureMembers>True</avrgcccpp.compiler.optimization.PackStructureMembers> <avrgcccpp.compiler.optimization.PackStructureMembers>True</avrgcccpp.compiler.optimization.PackStructureMembers>
<avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum> <avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcccpp.compiler.warnings.AllWarnings>True</avrgcccpp.compiler.warnings.AllWarnings> <avrgcccpp.compiler.warnings.AllWarnings>True</avrgcccpp.compiler.warnings.AllWarnings>
<avrgcccpp.compiler.miscellaneous.OtherFlags>-std=c++11</avrgcccpp.compiler.miscellaneous.OtherFlags> <avrgcccpp.compiler.miscellaneous.OtherFlags>-std=c++11</avrgcccpp.compiler.miscellaneous.OtherFlags>
<avrgcccpp.linker.libraries.Libraries><ListValues><Value>libm</Value></ListValues></avrgcccpp.linker.libraries.Libraries> <avrgcccpp.linker.libraries.Libraries>
<avrgcccpp.assembler.general.IncludePaths><ListValues><Value>%24(PackRepoDir)\Atmel\ATtiny_DFP\1.2.112\include</Value></ListValues></avrgcccpp.assembler.general.IncludePaths> <ListValues>
<avrgcc.compiler.symbols.DefSymbols><ListValues><Value>NDEBUG</Value></ListValues></avrgcc.compiler.symbols.DefSymbols> <Value>libm</Value>
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level> </ListValues>
<avrgcccpp.compiler.symbols.DefSymbols><ListValues><Value>NDEBUG</Value></ListValues></avrgcccpp.compiler.symbols.DefSymbols> </avrgcccpp.linker.libraries.Libraries>
<avrgcccpp.compiler.optimization.level>Optimize for size (-Os)</avrgcccpp.compiler.optimization.level> <avrgcccpp.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\Atmel\ATtiny_DFP\1.2.112\include</Value>
</ListValues>
</avrgcccpp.assembler.general.IncludePaths>
</AvrGccCpp> </AvrGccCpp>
</ToolchainSettings> </ToolchainSettings>
</PropertyGroup> </PropertyGroup>
@ -99,6 +123,7 @@
<avrgcccpp.compiler.miscellaneous.OtherFlags>-std=c++11</avrgcccpp.compiler.miscellaneous.OtherFlags> <avrgcccpp.compiler.miscellaneous.OtherFlags>-std=c++11</avrgcccpp.compiler.miscellaneous.OtherFlags>
<avrgcccpp.linker.libraries.Libraries><ListValues><Value>libm</Value></ListValues></avrgcccpp.linker.libraries.Libraries> <avrgcccpp.linker.libraries.Libraries><ListValues><Value>libm</Value></ListValues></avrgcccpp.linker.libraries.Libraries>
<avrgcccpp.assembler.general.IncludePaths><ListValues><Value>%24(PackRepoDir)\Atmel\ATtiny_DFP\1.2.112\include</Value></ListValues></avrgcccpp.assembler.general.IncludePaths> <avrgcccpp.assembler.general.IncludePaths><ListValues><Value>%24(PackRepoDir)\Atmel\ATtiny_DFP\1.2.112\include</Value></ListValues></avrgcccpp.assembler.general.IncludePaths>
<avrgcccpp.compiler.miscellaneous.Verbose>True</avrgcccpp.compiler.miscellaneous.Verbose>
<avrgcc.compiler.symbols.DefSymbols><ListValues><Value>DEBUG</Value></ListValues></avrgcc.compiler.symbols.DefSymbols> <avrgcc.compiler.symbols.DefSymbols><ListValues><Value>DEBUG</Value></ListValues></avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level> <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel> <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
@ -110,6 +135,12 @@
</ToolchainSettings> </ToolchainSettings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="DeviceLib\Lcd.cpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="DeviceLib\Lcd.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="DeviceLib\ShiftRegister.cpp"> <Compile Include="DeviceLib\ShiftRegister.cpp">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
@ -119,12 +150,24 @@
<Compile Include="Distancer.cpp"> <Compile Include="Distancer.cpp">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="hardware.cpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="hardware.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="LcdShiftReg.cpp"> <Compile Include="LcdShiftReg.cpp">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="LcdShiftReg.h"> <Compile Include="LcdShiftReg.h">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="MyLcd.cpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="MyLcd.h">
<SubType>compile</SubType>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="DeviceLib" /> <Folder Include="DeviceLib" />