Luka Pejovic Amra Dautbegovic

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 DigitalOut cifre[3] = {dp23, dp24, dp25};
00004 BusOut disp(dp4, dp2, dp1, dp28, dp6, dp5, dp27, dp26);
00005 //Novo za LV4
00006 AnalogIn ulaz(dp9);
00007 //end
00008 
00009 int _7sd(char znak, bool tocka = false)
00010 {
00011     //za sljedeci raspored: a b c d e f g dp
00012     //a to su dp26 dp27 dp5 dp6 dp28 dp1 dp2 dp4
00013     int t = !tocka;
00014     switch(znak)
00015     {
00016         case 'N':
00017             return 0xfe | t;
00018         case '0':
00019             return 0x02 | t;
00020         case '1':
00021             return 0x9e | t;
00022         case '2':
00023             return 0x24 | t;
00024         case '3':
00025             return 0x0c | t;
00026         case '4':
00027             return 0x98 | t;
00028         case '5':
00029             return 0x48 | t;
00030         case '6':
00031             return 0x40 | t;
00032         case '7':
00033             return 0x1a | t;
00034         case '8':
00035             return 0x00 | t;
00036         case '9':
00037             return 0x08 | t;
00038         case 'a': case 'A':
00039             return 0x10 | t;
00040         case 'b': case 'B':
00041             return 0xc0 | t;
00042         case 'c': case 'C':
00043             return 0x62 | t;
00044         case 'd': case 'D':
00045             return 0x84 | t;
00046         case 'e': case 'E':
00047             return 0x60 | t;
00048         case 'f': case 'F':
00049             return 0x70 | t;
00050         case '*':
00051             return 0x90 | t;
00052         case '#':
00053             return 0x6c | t;
00054     }
00055 }
00056 
00057 
00058 void ispisi(int broj){
00059     int znakovi[3] = {(broj%1000)/100, (broj%100)/10, broj%10};
00060     for(int i = 0; i < 3; i++){
00061         cifre[i] = 0;
00062         disp = _7sd(znakovi[i] + '0', i == 0); //tacku na prvom
00063         wait(0.0025);  //ovo mijenjati da se ustima bolje svjetlo
00064         cifre[i] = 1;
00065     }
00066 }
00067 
00068 int main() {
00069     //char c, c1;
00070     int counter = 0;
00071     float pot, suma;
00072     wait(0.05);
00073     char niz[3] = {'8', '3','9'};
00074     
00075     pot = ulaz;
00076     while(1){
00077             if(counter == 50){
00078                 pot = suma/50.f;
00079                 counter = 0;
00080                 suma = 0;
00081             }
00082             ispisi(pot * 330.f);
00083             suma += ulaz;
00084             counter++;
00085     }
00086 
00087 }