Small Change
Dependencies: APDS_9960 TextLCD mbed
Fork of Si4703 by
main.cpp@2:8f479ed18d48, 2017-03-20 (annotated)
- Committer:
- nciulla
- Date:
- Mon Mar 20 17:48:47 2017 +0000
- Revision:
- 2:8f479ed18d48
- Parent:
- 1:563a11fe39e0
- Child:
- 3:189500a3c510
works
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Gjika | 1:563a11fe39e0 | 1 | #include "mbed.h" |
Gjika | 1:563a11fe39e0 | 2 | #include "SparkFun-Si4703.h" |
Gjika | 1:563a11fe39e0 | 3 | #include "TextLCD.h" |
Gjika | 1:563a11fe39e0 | 4 | |
Gjika | 1:563a11fe39e0 | 5 | Serial pc(USBTX, USBRX); |
nciulla | 2:8f479ed18d48 | 6 | Si4703_Breakout radio(PTD9, PTD8, PTB11, &pc); // (sda, scl, rst, Serial) PTD9, PTD8, PTB11, &pc); |
nciulla | 2:8f479ed18d48 | 7 | DigitalIn chanUp(PTA12); |
nciulla | 2:8f479ed18d48 | 8 | DigitalIn chanDown(PTA13); |
nciulla | 2:8f479ed18d48 | 9 | DigitalIn volUp(PTC16); |
nciulla | 2:8f479ed18d48 | 10 | DigitalIn volDown(PTC17); |
nciulla | 2:8f479ed18d48 | 11 | TextLCD lcd(PTE6, PTD15, PTD4, PTD5, PTD6, PTD7); // rs, e, d4-d7 |
Gjika | 1:563a11fe39e0 | 12 | |
Gjika | 1:563a11fe39e0 | 13 | |
Gjika | 1:563a11fe39e0 | 14 | |
Gjika | 1:563a11fe39e0 | 15 | int main(int argc, char** argv) { |
Gjika | 1:563a11fe39e0 | 16 | |
nciulla | 2:8f479ed18d48 | 17 | int chan = 963; |
Gjika | 1:563a11fe39e0 | 18 | int vol = 9; |
Gjika | 1:563a11fe39e0 | 19 | radio.powerOn(); |
Gjika | 1:563a11fe39e0 | 20 | radio.setVolume(vol); // range: 0-15 |
Gjika | 1:563a11fe39e0 | 21 | radio.setChannel(chan); // 90.1 WABE |
Gjika | 1:563a11fe39e0 | 22 | |
Gjika | 1:563a11fe39e0 | 23 | lcd.cls(); |
Gjika | 1:563a11fe39e0 | 24 | lcd.printf("channel = '%d'", radio.getChannel()); |
Gjika | 1:563a11fe39e0 | 25 | lcd.printf(" volume = '%d'\n", radio.getVolume()); |
Gjika | 1:563a11fe39e0 | 26 | pc.printf("channel = '%d'", radio.getChannel()); |
Gjika | 1:563a11fe39e0 | 27 | pc.printf(" volume = '%d'\n", radio.getVolume()); |
Gjika | 1:563a11fe39e0 | 28 | |
Gjika | 1:563a11fe39e0 | 29 | |
nciulla | 2:8f479ed18d48 | 30 | // while(1){ |
nciulla | 2:8f479ed18d48 | 31 | // if(chanUp) { |
nciulla | 2:8f479ed18d48 | 32 | // chan++; |
nciulla | 2:8f479ed18d48 | 33 | // radio.setChannel(chan); |
nciulla | 2:8f479ed18d48 | 34 | // lcd.cls(); |
nciulla | 2:8f479ed18d48 | 35 | // lcd.printf("channel = '%d'", radio.getChannel()); |
nciulla | 2:8f479ed18d48 | 36 | // lcd.printf(" volume = '%d'\n", radio.getVolume()); |
nciulla | 2:8f479ed18d48 | 37 | // pc.printf("channel = '%d'", radio.getChannel()); |
nciulla | 2:8f479ed18d48 | 38 | // pc.printf(" volume = '%d'\n", radio.getVolume()); |
nciulla | 2:8f479ed18d48 | 39 | // wait(.25); |
nciulla | 2:8f479ed18d48 | 40 | // } |
nciulla | 2:8f479ed18d48 | 41 | // if(chanDown) { |
nciulla | 2:8f479ed18d48 | 42 | // chan--; |
nciulla | 2:8f479ed18d48 | 43 | // radio.setChannel(chan); |
nciulla | 2:8f479ed18d48 | 44 | // lcd.cls(); |
nciulla | 2:8f479ed18d48 | 45 | // lcd.printf("channel = '%d'", radio.getChannel()); |
nciulla | 2:8f479ed18d48 | 46 | // lcd.printf(" volume = '%d'\n", radio.getVolume()); |
nciulla | 2:8f479ed18d48 | 47 | // pc.printf("channel = '%d'", radio.getChannel()); |
nciulla | 2:8f479ed18d48 | 48 | // pc.printf(" volume = '%d'\n", radio.getVolume()); |
nciulla | 2:8f479ed18d48 | 49 | // wait(.25); |
nciulla | 2:8f479ed18d48 | 50 | // } |
nciulla | 2:8f479ed18d48 | 51 | // if(volUp && vol <= 14) { |
nciulla | 2:8f479ed18d48 | 52 | // vol++; |
nciulla | 2:8f479ed18d48 | 53 | // radio.setVolume(vol); |
nciulla | 2:8f479ed18d48 | 54 | // lcd.cls(); |
nciulla | 2:8f479ed18d48 | 55 | // lcd.printf("channel = '%d'", radio.getChannel()); |
nciulla | 2:8f479ed18d48 | 56 | // lcd.printf(" volume = '%d'\n", radio.getVolume()); |
nciulla | 2:8f479ed18d48 | 57 | // pc.printf("channel = '%d'", radio.getChannel()); |
nciulla | 2:8f479ed18d48 | 58 | // pc.printf(" volume = '%d'\n", radio.getVolume()); |
nciulla | 2:8f479ed18d48 | 59 | // wait(.25); |
nciulla | 2:8f479ed18d48 | 60 | // } |
nciulla | 2:8f479ed18d48 | 61 | // if(volUp && vol == 15) { |
nciulla | 2:8f479ed18d48 | 62 | // lcd.cls(); |
nciulla | 2:8f479ed18d48 | 63 | // lcd.printf("channel = '%d'", radio.getChannel()); |
nciulla | 2:8f479ed18d48 | 64 | // lcd.printf(" Max Volume\n", radio.getVolume()); |
nciulla | 2:8f479ed18d48 | 65 | // pc.printf("Max Volume\n"); |
nciulla | 2:8f479ed18d48 | 66 | // wait(.25); |
nciulla | 2:8f479ed18d48 | 67 | // } |
nciulla | 2:8f479ed18d48 | 68 | // if(volDown && vol >= 1) { |
nciulla | 2:8f479ed18d48 | 69 | // vol--; |
nciulla | 2:8f479ed18d48 | 70 | // radio.setVolume(vol); |
nciulla | 2:8f479ed18d48 | 71 | // lcd.cls(); |
nciulla | 2:8f479ed18d48 | 72 | // lcd.printf("channel = '%d'", radio.getChannel()); |
nciulla | 2:8f479ed18d48 | 73 | // lcd.printf(" volume = '%d'\n", radio.getVolume()); |
nciulla | 2:8f479ed18d48 | 74 | // pc.printf("channel = '%d'", radio.getChannel()); |
nciulla | 2:8f479ed18d48 | 75 | // pc.printf(" volume = '%d'\n", radio.getVolume()); |
nciulla | 2:8f479ed18d48 | 76 | // wait(.25); |
nciulla | 2:8f479ed18d48 | 77 | // } |
nciulla | 2:8f479ed18d48 | 78 | // if(volDown && vol == 0) { |
nciulla | 2:8f479ed18d48 | 79 | // lcd.cls(); |
nciulla | 2:8f479ed18d48 | 80 | // lcd.printf("channel = '%d'", radio.getChannel()); |
nciulla | 2:8f479ed18d48 | 81 | // lcd.printf(" Min Volume\n", radio.getVolume()); |
nciulla | 2:8f479ed18d48 | 82 | // pc.printf("Min Volume\n"); |
nciulla | 2:8f479ed18d48 | 83 | // wait(.25); |
nciulla | 2:8f479ed18d48 | 84 | // } |
nciulla | 2:8f479ed18d48 | 85 | // |
nciulla | 2:8f479ed18d48 | 86 | // } |
Gjika | 1:563a11fe39e0 | 87 | } |