Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of ProgettoAUC by
Revision 4:98e062cf962e, committed 2016-11-28
- Comitter:
- marcovitone
- Date:
- Mon Nov 28 15:44:32 2016 +0000
- Parent:
- 3:4ce3bb78b1fc
- Child:
- 5:a38af5651374
- Commit message:
- progetto finale
Changed in this revision
TextLCD.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Mon Nov 28 15:44:32 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/simon/code/TextLCD/#308d188a2d3a
--- a/main.cpp Mon Nov 21 12:13:28 2016 +0000 +++ b/main.cpp Mon Nov 28 15:44:32 2016 +0000 @@ -1,8 +1,10 @@ #include "mbed.h" +#include "TextLCD.h" //TEA5767 example with STM32 nucleo //Developed by Mazzella, Vitone, Tarallo +TextLCD lcd(D12, D11, D5, D4, D3, D2, TextLCD::LCD16x2); I2C radio(D14, D15); //sda, sc1 AnalogIn trimmer(PA_0);// A0 ingresso analogico @@ -10,7 +12,7 @@ InterruptIn button (USER_BUTTON); char s; float frequenza; -int N; +unsigned int N,m1,m2; const int addr = 0xC0; //address for writing data, reading is C1 @@ -19,7 +21,7 @@ char lettura[5]; -void seqfreq() //search next frequency, minimun signal strength +/*void seqfreq() //search next frequency, minimun signal strength { search[0] = 0x6F; search[1] = 0xCA; @@ -34,7 +36,7 @@ -} +}*/ @@ -42,16 +44,27 @@ { while (1){ frequenza=(108-87.5)*trimmer.read()+87.5; - N=4*(frequenza+225000)/32768; + N=4*(frequenza*1e6+225000)/32768; + /*pc.printf("Frequenza = \n\r"); + pc.printf("%1.3f",frequenza); + pc.printf("\n\r");*/ //a questo punto dobbiamo converitre in esadecimale N ed inviarlo al modulo radio + // usando unsigned int n sappiamo con sicurezza di utilizzare solo 2 byte + m2=N & 0x00FF;//isoliamo il secondo byte di N + m1=N& 0xFF00;//isoliamo il primo byte di N,dobbiamo però shifarlo + m1=m1>>8; - config_t[0] = 0x2F; - config_t[1] = 0xCA; // config data byte, tune at 100.00MHz + config_t[0] = char(m1); + config_t[1] = char(m2); // config data byte, tune at 100.00MHz config_t[2] = 0x10; config_t[3] = 0x12; config_t[4] = 0x00; radio.write(addr, config_t, 5); - button.rise(&seqfreq); + lcd.locate(0,0); + lcd.printf("Frequenza:" ,frequenza); + wait(1); + } + // button.rise(&seqfreq); }