My basic operation system for STM32 MCU

Committer:
Hagrid
Date:
Sun Feb 24 17:41:44 2019 +0000
Revision:
3:5047e6339308
Parent:
0:5f09301c4a9c
Add nextion page and progress bar fce

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Hagrid 0:5f09301c4a9c 1 #include "PonyxisOS.h"
Hagrid 0:5f09301c4a9c 2
Hagrid 0:5f09301c4a9c 3 Nextion nextion(PA_0, PA_1);
Hagrid 0:5f09301c4a9c 4
Hagrid 0:5f09301c4a9c 5 PonyxisOS::PonyxisOS() {}
Hagrid 0:5f09301c4a9c 6
Hagrid 0:5f09301c4a9c 7 void PonyxisOS::begin()
Hagrid 0:5f09301c4a9c 8 {
Hagrid 0:5f09301c4a9c 9 _actline = 0;
Hagrid 0:5f09301c4a9c 10 nextion.init();
Hagrid 3:5047e6339308 11 nextion.page(0);
Hagrid 3:5047e6339308 12 nextion.setProgress("j0", 100);
Hagrid 3:5047e6339308 13 wait(0.5);
Hagrid 3:5047e6339308 14 nextion.page(1);
Hagrid 0:5f09301c4a9c 15 }
Hagrid 0:5f09301c4a9c 16
Hagrid 0:5f09301c4a9c 17 void PonyxisOS::print(char *_data)
Hagrid 0:5f09301c4a9c 18 {
Hagrid 0:5f09301c4a9c 19 size_t _len = strlen(_data);
Hagrid 0:5f09301c4a9c 20 for (size_t i = 0; i < _len; i++) {
Hagrid 0:5f09301c4a9c 21 _screen[_y][_x] = _data[i];
Hagrid 0:5f09301c4a9c 22 _x++;
Hagrid 0:5f09301c4a9c 23 if (_data[i] == '\n') {
Hagrid 0:5f09301c4a9c 24 Render();
Hagrid 0:5f09301c4a9c 25 _actline++;
Hagrid 0:5f09301c4a9c 26 _x = 0;
Hagrid 0:5f09301c4a9c 27 _y++;
Hagrid 0:5f09301c4a9c 28 }
Hagrid 0:5f09301c4a9c 29 }
Hagrid 0:5f09301c4a9c 30 Render();
Hagrid 0:5f09301c4a9c 31 }
Hagrid 0:5f09301c4a9c 32
Hagrid 0:5f09301c4a9c 33 void PonyxisOS::Render()
Hagrid 0:5f09301c4a9c 34 {
Hagrid 0:5f09301c4a9c 35 switch (_actline) {
Hagrid 0:5f09301c4a9c 36 case 0:
Hagrid 0:5f09301c4a9c 37 nextion.setText("t0", _screen[0]);
Hagrid 0:5f09301c4a9c 38 break;
Hagrid 0:5f09301c4a9c 39 case 1:
Hagrid 0:5f09301c4a9c 40 nextion.setText("t1", _screen[1]);
Hagrid 0:5f09301c4a9c 41 break;
Hagrid 0:5f09301c4a9c 42 case 2:
Hagrid 0:5f09301c4a9c 43 nextion.setText("t2", _screen[2]);
Hagrid 0:5f09301c4a9c 44 break;
Hagrid 0:5f09301c4a9c 45 case 3:
Hagrid 0:5f09301c4a9c 46 nextion.setText("t3", _screen[3]);
Hagrid 0:5f09301c4a9c 47 break;
Hagrid 0:5f09301c4a9c 48 case 4:
Hagrid 0:5f09301c4a9c 49 nextion.setText("t4", _screen[4]);
Hagrid 0:5f09301c4a9c 50 break;
Hagrid 0:5f09301c4a9c 51 case 5:
Hagrid 0:5f09301c4a9c 52 nextion.setText("t5", _screen[5]);
Hagrid 0:5f09301c4a9c 53 break;
Hagrid 0:5f09301c4a9c 54 case 6:
Hagrid 0:5f09301c4a9c 55 nextion.setText("t6", _screen[6]);
Hagrid 0:5f09301c4a9c 56 break;
Hagrid 0:5f09301c4a9c 57 case 7:
Hagrid 0:5f09301c4a9c 58 nextion.setText("t7", _screen[7]);
Hagrid 0:5f09301c4a9c 59 break;
Hagrid 0:5f09301c4a9c 60 case 8:
Hagrid 0:5f09301c4a9c 61 nextion.setText("t8", _screen[8]);
Hagrid 0:5f09301c4a9c 62 break;
Hagrid 0:5f09301c4a9c 63 case 9:
Hagrid 0:5f09301c4a9c 64 nextion.setText("t9", _screen[9]);
Hagrid 0:5f09301c4a9c 65 break;
Hagrid 0:5f09301c4a9c 66 case 10:
Hagrid 0:5f09301c4a9c 67 nextion.setText("t10", _screen[10]);
Hagrid 0:5f09301c4a9c 68 break;
Hagrid 0:5f09301c4a9c 69 case 11:
Hagrid 0:5f09301c4a9c 70 nextion.setText("t11", _screen[11]);
Hagrid 0:5f09301c4a9c 71 break;
Hagrid 0:5f09301c4a9c 72 case 12:
Hagrid 0:5f09301c4a9c 73 nextion.setText("t12", _screen[12]);
Hagrid 0:5f09301c4a9c 74 break;
Hagrid 0:5f09301c4a9c 75 case 13:
Hagrid 0:5f09301c4a9c 76 nextion.setText("t13", _screen[13]);
Hagrid 0:5f09301c4a9c 77 break;
Hagrid 0:5f09301c4a9c 78 case 14:
Hagrid 0:5f09301c4a9c 79 nextion.setText("t14", _screen[14]);
Hagrid 0:5f09301c4a9c 80 break;
Hagrid 0:5f09301c4a9c 81 case 15:
Hagrid 0:5f09301c4a9c 82 nextion.setText("t15", _screen[15]);
Hagrid 0:5f09301c4a9c 83 break;
Hagrid 0:5f09301c4a9c 84 case 16:
Hagrid 0:5f09301c4a9c 85 nextion.setText("t16", _screen[16]);
Hagrid 0:5f09301c4a9c 86 break;
Hagrid 0:5f09301c4a9c 87 case 17:
Hagrid 0:5f09301c4a9c 88 nextion.setText("t17", _screen[17]);
Hagrid 0:5f09301c4a9c 89 break;
Hagrid 0:5f09301c4a9c 90 }
Hagrid 0:5f09301c4a9c 91 }