diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ffac913..65f40be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,3 +1,5 @@ +name: panflute tests + on: # Trigger the workflow on push or pull request, # but only for the master branch @@ -18,4 +20,4 @@ jobs: - name: Install dependencies run: cd board && sh install.sh - name: Build PanFLUte firmware - run: cd board && make + run: cd board && make \ No newline at end of file diff --git a/README.md b/README.md index d2a02bf..7e79f94 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@

-[![Build Status](http://img.shields.io/travis/COVID-19-electronic-health-system/PanFLUte/master.svg?style=for-the-badge)](https://travis-ci.org/COVID-19-electronic-health-system/PanFLUte) +![panflute tests](https://github.com/COVID-19-electronic-health-system/PanFLUte/workflows/panflute%20tests/badge.svg) PanFLUte (Pneumonia analyzing node for FLU to everyone) is an open source spirometer. It is used to measures the amount of air you're able to breathe in and out. diff --git a/board/Makefile b/board/Makefile index 5d23fe3..b4c0473 100644 --- a/board/Makefile +++ b/board/Makefile @@ -3,7 +3,7 @@ PROGRAMMER=atmelice_isp F_CPU=1000000 CC=avr-gcc OBJCOPY=avr-objcopy -CFLAGS=-Wall -g -Os -mmcu=${MCU} -DF_CPU=${F_CPU} -Wl,-u,vfprintf +CFLAGS=-Wall -g -Os -mmcu=${MCU} -DF_CPU=${F_CPU} -Wl,-u,vfprintf -lprintf_flt -lm TARGET=main SRC=main.c ADC_LIB=adc/adc.c diff --git a/board/adc/adc.c b/board/adc/adc.c index 7bf7c08..64397b4 100644 --- a/board/adc/adc.c +++ b/board/adc/adc.c @@ -3,11 +3,19 @@ void adcInit(void) { /* Enable ADC */ - ADCSRA |= (1 << ADEN); + ADCSRA = (1 << ADEN) | (1 << ADSC); /* Left Adjust Results */ - ADCSRB |= (1 << ADLAR); + //ADCSRB = (1 << ADLAR); + //printf("ADC has started\n"); } +/* +void getPSI(void) { + ADCSRA |= (1 << ADSC); // Start ADC conversion + float rawPresureData = ADCH; // Max is 8bit value + printf("PSI: %.2f", (rawPresureData / 255.0) * 14.5); + delay_ms(100); +} uint8_t adcStart(void) { ADCSRA |= (1 << ADSC); // Start ADC conversion @@ -16,3 +24,4 @@ uint8_t adcStart(void) { return rawPresureData; } +*/ diff --git a/board/driver/adc.h b/board/driver/adc.h index 8774184..06147ca 100644 --- a/board/driver/adc.h +++ b/board/driver/adc.h @@ -1,5 +1,7 @@ #include #include +#define OFFSET 44 void adcInit(void); -uint8_t adcStart(void); +//void getPSI(void); +//uint8_t adcStart(void); diff --git a/board/driver/mpx5100.h b/board/driver/mpx5100.h index 1d77d7b..017bd68 100644 --- a/board/driver/mpx5100.h +++ b/board/driver/mpx5100.h @@ -1 +1,3 @@ +#include "../driver/adc.h" // #define SIGNAL_OFFSET // This value corresponds to an air flow of 0 + diff --git a/board/driver/usart.h b/board/driver/usart.h index a6ed3ba..6a7b304 100644 --- a/board/driver/usart.h +++ b/board/driver/usart.h @@ -8,4 +8,3 @@ void usartInit(unsigned int ubrr); void usartTransmit(unsigned char data); unsigned char usartReceive(void); int print(char c, FILE *stream); - diff --git a/board/firmware/main.bin b/board/firmware/main.bin index 6f3e45a..311d1aa 100755 Binary files a/board/firmware/main.bin and b/board/firmware/main.bin differ diff --git a/board/firmware/main.hex b/board/firmware/main.hex index ff16a90..694d83f 100644 --- a/board/firmware/main.hex +++ b/board/firmware/main.hex @@ -1,7 +1,121 @@ -:100000001DC024C023C022C021C020C01FC01EC0EC -:100010001DC01CC01BC01AC019C018C017C016C014 -:1000200015C014C013C012C011C010C00FC00EC044 -:100030000DC00CC00BC00AC009C008C011241FBEEF -:10004000CFEFD1E0DEBFCDBF02D002C0D9CFFFCF0E -:04005000F894FFCF52 +:100000001DC037C036C035C034C033C032C031C067 +:1000100030C02FC02EC02DC02CC02BC02AC029C07C +:1000200028C027C026C025C024C023C022C021C0AC +:1000300020C01FC01EC01DC01CC01BC011241FBE7D +:10004000CFEFD1E0DEBFCDBF11E0A0E0B1E0EEE543 +:10005000F7E002C005900D92AE31B107D9F721E06B +:10006000AEE1B1E001C01D92A832B207E1F759D06C +:1000700074C3C6CFC09A2FE986E891E02150804032 +:100080009040E1F700C00000C09883E294EF019730 +:10009000F1F700C00000089580EC85B908959093B1 +:1000A00082008093810088E18093850086E08093C0 +:1000B000840082E08093860008959091860095FFE9 +:1000C000FCCF8093800008958091860087FFFCCF4D +:1000D0008091800008959091860095FFFCCF8093D9 +:1000E000800080E090E00895D19A089520E030E00B +:1000F0002817390749F0E9EFF0E03197F1F700C030 +:1001000000002F5F3F4FF4CF0895CF93DF93EC01B2 +:10011000D89AECDFD898CE0196958795DF91CF914C +:10012000E5CF81E087BBB8DF8CE090E0B8DF80E00E +:1001300091E09093250180932401CEE0D1E02E99A7 +:10014000FECF2E9A26B130E030932101209320017A +:1001500087B190E06FEF70E017D0820F931F9093FC +:100160001F0180931E018C979F938F93DF93CF93F2 +:100170001CD08BE792E90197F1F700C000000F90C7 +:100180000F900F900F90DBCF0024552704C0080E6E +:10019000591F880F991F009729F076956795B8F336 +:1001A0007105B9F7802D952F0895A0E0B0E0EAED34 +:1001B000F0E0ACC2AE014B5F5F4FFA01619171910B +:1001C000AF01809124019091250102D0E2E0BAC2F2 +:1001D000ABE0B0E0EDEEF0E089C26C017B018A019A +:1001E000FC0117821682838181FFC0C1CE01019676 +:1001F0003C01F6019381F70193FD859193FF819175 +:100200007F01882309F4AEC1853239F493FD8591CD +:1002100093FF81917F01853221F4B60190E0C1D135 +:10022000E8CF912C212C312CFFE1F315E0F08B323B +:1002300079F038F4803279F08332A9F4232D2061EB +:1002400010C08D3259F0803371F4232D216009C024 +:10025000832D8260382EE32DE46022C0F32DF860F8 +:1002600025C0322E27C037FC2DC020ED280F2A30A4 +:1002700088F436FE06C0892D6AE02FD2922E980EA1 +:1002800019C0822D6AE029D2222E280E832D806289 +:10029000382E10C08E3231F436FC64C1E32DE06498 +:1002A0003E2E08C08C3621F4F32DF0683F2E02C09C +:1002B000883641F4F70193FD859193FF81917F0189 +:1002C0008111B2CF982F9F7D9554933028F40C5F05 +:1002D0001F4F2FE329830DC0833631F0833771F030 +:1002E000833509F055C020C0F801808189830E5FF5 +:1002F0001F4F88248394912C530112C02801F2E0EF +:100300004F0E511CF801A080B18036FE03C0692D4C +:1003100070E002C06FEF7FEFC50138D14C01820160 +:10032000F32DFF773F2E15C0280122E0420E511C0D +:10033000F801A080B18036FE03C0692D70E002C0D4 +:100340006FEF7FEFC50117D14C01F32DF0683F2E01 +:10035000820133FC19C0822D90E088169906A0F422 +:10036000B60180E290E01DD12A94F5CFF50137FC6B +:10037000859137FE81915F01B60190E012D1211085 +:100380002A9421E0821A91088114910479F7E1C03E +:10039000843611F0893639F5F80137FE07C06081DF +:1003A0007181828193810C5F1F4F08C060817181D0 +:1003B000072E000C880B990B0E5F1F4FF32DFF7655 +:1003C0003F2E97FF09C090958095709561957F4F5E +:1003D0008F4F9F4FF0683F2E2AE030E0A3011DD1E0 +:1003E000882E861844C0853731F4232D2F7EB22EF7 +:1003F0002AE030E025C0932D997FB92E8F36C1F0C9 +:1004000018F4883579F0AEC0803719F0883721F0BC +:10041000A9C0E92FE061BE2EB4FE0DC0FB2DF46033 +:10042000BF2E09C034FE0AC0292F2660B22E06C096 +:1004300028E030E005C020E130E002C020E132E0F9 +:10044000F801B7FE07C060817181828193810C5FE2 +:100450001F4F06C06081718180E090E00E5F1F4FEA +:10046000A301DBD0882E8618FB2DFF773F2E36FEAA +:100470000DC0232D2E7FA22E891458F434FE0BC0FC +:1004800032FC09C0832D8E7EA82E05C0B82CA32C6B +:1004900003C0B82C01C0B92CA4FE0FC0FE01E80DAA +:1004A000F11D8081803321F49A2D997EA92E09C0F7 +:1004B000A2FE06C0B394B39404C08A2D867809F0D6 +:1004C000B394A3FC10C0A0FE06C0B21480F4280CA4 +:1004D000922C9B180DC0B21458F4B60180E290E043 +:1004E00060D0B394F8CFB21418F42B1802C0982C33 +:1004F000212CA4FE0FC0B60180E390E052D0A2FEF2 +:1005000016C0A1FC03C088E790E002C088E590E037 +:10051000B6010CC08A2D867851F0A1FE02C08BE294 +:1005200001C080E2A7FC8DE2B60190E03AD08914C8 +:1005300030F4B60180E390E034D09A94F8CF8A94F6 +:10054000F301E80DF11D8081B60190E02AD0811001 +:10055000F6CF222009F44DCEB60180E290E021D002 +:100560002A94F7CFF6018681978102C08FEF9FEF23 +:100570002B96E2E1D7C0FC0105906150704001105C +:10058000D8F7809590958E0F9F1F0895FC016150BC +:10059000704001900110D8F7809590958E0F9F1FA5 +:1005A00008950F931F93CF93DF93FB01238121FDC8 +:1005B00003C08FEF9FEF2CC022FF16C046815781EA +:1005C000248135814217530744F4A081B1819D01F4 +:1005D0002F5F3F4F318320838C93268137812F5F9C +:1005E0003F4F3783268314C08B01EC01FB0100844D +:1005F000F185E02D0995892BE1F6D80116968D91AC +:100600009C911797019617969C938E931697CE01FF +:10061000DF91CF911F910F910895FA01AA272830F9 +:1006200061F1203191F1E8946F936E7F6E5F7F4F9F +:100630008F4F9F4FAF4FB1E040D0B4E03ED0670F37 +:10064000781F891F9A1FA11D680F791F8A1F911D8E +:10065000A11D6A0F711D811D911DA11D22D009F4DC +:1006600068943F91062E000C3019000C000C3019D4 +:10067000305D3193CEF6CF010895462F4770405D2F +:100680004193B3E00FD0C9F7F6CF462F4F70405DCE +:100690004A3318F0495D31FD4052419302D0A9F729 +:1006A000EACFB4E0A6959795879577956795BA9523 +:1006B000C9F700976105710508959B01AC010A2EE9 +:1006C00006945795479537952795BA95C9F7620FC0 +:1006D000731F841F951FA01D0895002480FD060E22 +:1006E000660F11F08695D1F7802D08952F923F92D5 +:1006F0004F925F926F927F928F929F92AF92BF9232 +:10070000CF92DF92EF92FF920F931F93CF93DF93DD +:10071000CDB7DEB7CA1BDB0B0FB6F894DEBF0FBE3A +:10072000CDBF09942A88398848885F846E847D8487 +:100730008C849B84AA84B984C884DF80EE80FD8089 +:100740000C811B81AA81B981CE0FD11D0FB6F894FF +:0E075000DEBF0FBECDBFED010895F894FFCFC0 +:10075E0000000003000000006B00000000003130BC +:0E076E0020626974204144433A2025640A0049 :00000001FF diff --git a/board/main.c b/board/main.c index 3823f0e..7e9c3cd 100644 --- a/board/main.c +++ b/board/main.c @@ -1,16 +1,18 @@ #include "driver/usart.h" -#include "driver/led.h" +#include "driver/led.h" #include "driver/adc.h" static FILE mystdout = FDEV_SETUP_STREAM(print, NULL, _FDEV_SETUP_RW); -int main(void) { +int main(void) { adcInit(); usartInit(MYUBRR); stdout = &mystdout; - while(1) { - printf("Should be sensor data: %d\n", adcStart()); - delay_ms(1000); - } - return 0; + while(1) { + while(ADCSRA & (1 << ADSC)); + ADCSRA |= (1 << ADSC); // Start ADC conversion + // TODO: Must subtract ADCH from offset. + printf("PSI: %.2f\n", (ADCH / 255.0) * 14.5); + delay_ms(150); + } }