n/a
Dependencies: Circle Rectangle Shape Square mbed
Diff: main.cpp
- Revision:
- 0:2f3ce9b79d39
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 22 09:30:29 2016 +0000 @@ -0,0 +1,113 @@ +#include "Shape.h" +#include "Circle.h" +#include "Rectangle.h" +#include "Square.h" +#include "mbed.h" +#include <string> + +extern Serial pc(USBTX, USBRX); + +DigitalOut led(LED1); +DigitalIn pb(USER_BUTTON); +DigitalIn pb2(PC_8); + +int count = 0; +int counter() +{ + return ++count; +} + +int counter2() +{ + static int count2 = 0; + return ++count2; + pc.printf("\n\r Count2 : %d", count2); +} + + +int main() +{ + pc.format(8,SerialBase::None,1); + pc.baud(115200); + + + + pb.mode(PullUp); + bool off = 0; + + pc.printf("\n\r START\n\r"); // napisz------------------ + + int licznikGuzika = 0; + //int licznikGuzika2 = 0; + + struct fish { + const char *name; + const char *species; + int teeth; + int age; + }; + +//-----------------------PETLA----------------------------------------------------- + while(1) { + + static int licznikGuzika2 = 0; + + struct fish snappy = {"Snappy", "Piranha", 69, 4}; + + if (pb == 0) { + off = !off; + if (off) { + licznikGuzika++; + licznikGuzika2++; + led = !led; + + pc.printf("\n\r Nazwa : %s", snappy.name); + + counter(); + pc.printf("\n\r Count : %d", count); + counter2(); + + + Shape * papers[5]; + + Circle michael(1.0); + Rectangle andrew(2.0,4.0); + Circle ann(10); + Square tim(100); + Rectangle jonathan(20.0,25.0); + + papers[0] = &michael; papers[1] = &andrew; papers[2] = &ann; + papers[3] = &tim; papers[4] = &jonathan; + + for (int k=0; k<5; k++) { + pc.printf("\n\rArea is %f", papers[k]->getArea()); + } + + + } + if (!off) { + licznikGuzika++; + licznikGuzika2++; + led = !led; + + pc.printf("\n\rNazwa : %s", snappy.species); + + counter(); + pc.printf("\n\r Count : %d", count); + counter2(); + + + + } + + while (pb == 0); + } + + +//-------------------------CHECK------------------------------------------ + if (pb2 == 0) { + + + } + } +} \ No newline at end of file