![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
RAM error
Dependencies: F746_GUI mbed StepperMotorX2Y
main.cpp
- Committer:
- Abdel64
- Date:
- 2020-11-11
- Revision:
- 0:fda2fbc0d37b
- Child:
- 1:39faa12c5a52
File content as of revision 0:fda2fbc0d37b:
//----------------------------------------------------------------------- // GuiBase とその派生クラスのデモプログラム // Demo program for GuiBase class and its derivertive classes // // GuiBase, Button, ButtonGroup, Label, NumericLabel, BlinkLabel, // SeekBar, SeekbarGroup, NumericUpDown // // <インポートしたライブラリのリビジョン> // F746_GUI 33 // mbed 161 // // 2018/03/12, Copyright (c) 2018 MIKAMI, Naoki //----------------------------------------------------------------------- #include "F746_GUI.hpp" #include "Stepper.h" DigitalIn FourcheLibre(PA_8); int speed_start = 10; int speed_max = 1000; int main() { // ******** INIT GUI ********* NumericLabel<int> bStart(380, 240, "Wait for Start", Label::LEFT, Font12, LCD_COLOR_MAGENTA); Button Start(250, 220, 120, 40, "START", Font12, GuiBase::ENUM_TEXT, GuiBase::ENUM_BACK, LCD_COLOR_DARKGREEN, LCD_COLOR_GREEN); Label stepY(130, 20, "STEPPERs Y", Label::CENTER, Font16); ButtonGroup bDir_Y(50, 70, 80, 50, 3, (string[]){"^","v","Pause"}, 0, 0, 2); bDir_Y.TouchedColor(2); NumericLabel<int> bDir_Y_label(130, 35, "", Label::CENTER , Font12); bDir_Y_label.Draw("Pause",1); NumericLabel<int> bCount_Y_label(130, 50, "", Label::CENTER , Font12); bCount_Y_label.Draw("Not started",1); Label stepX(320, 20, "STEPPER X", Label::CENTER, Font16); ButtonGroup bDir_X(260, 70, 80, 50, 3, (string[]){"<<",">>","Pause"}, 0, 0, 2); bDir_X.TouchedColor(2); NumericLabel<int> bDir_X_label(320, 35, "", Label::CENTER , Font12); bDir_X_label.Draw("Pause",1); NumericLabel<int> bCount_X_label(320, 50, "", Label::CENTER , Font12); bCount_X_label.Draw("Not started",1); SeekBar barSpeed(20, 250, 200, 0, speed_max, speed_start, "0", "", "1000"); NumericLabel<int> barSpeed_legend(110, 205, "Speed : 10", Label::CENTER , Font12); barSpeed_legend.Draw("Speed : %d",barSpeed.GetIntValue()); // ******** INIT STEPPER ****** // stepper(PinName _en, PinName _stepPin, PinName dirG, PinName dirD) steppers Steppers_Y (PB_8,PB_9,PB_14,PB_15); Steppers_Y.disable(); stepper Stepper_X (PB_4,PC_6,PC_7); Stepper_X.disable(); int Y_en, Y_dir, X_en, X_dir, Y_speed, X_speed, Y_count, X_count ; Y_speed = X_speed = speed_start; Y_en = X_en = 0; Y_count = X_count = 0; int first = 1; int num; // ***** WAIT FOR START ***** while(!Start.Touched()){ if (first){ bStart.Draw("Wait for Start",0); first = 0; } } // ******* RUN ***** // ***************** first = 1; while (true) { if (first){ bStart.Draw("Started",1); first = 0; } if (barSpeed.Slide()){ Y_speed = barSpeed.GetIntValue(); X_speed = Y_speed; barSpeed_legend.Draw("Speed : %d",barSpeed.GetIntValue()); } if (bDir_Y.GetTouchedNumber(num)){ switch (num) { case 0: Y_en = 1; Y_dir = 1; bDir_Y_label.Draw("Avant (dir:%d)",Y_dir); break; case 1: Y_en = 1; Y_dir = 0; bDir_Y_label.Draw("Arriere (dir:%d)",Y_dir); break; case 2: Y_en = 0; bDir_Y_label.Draw("Pause",0); break; } } if (bDir_X.GetTouchedNumber(num)){ switch (num) { case 0: X_en = 1; X_dir = 1; bDir_X_label.Draw("Gauche (dir:%d)",X_dir); break; case 1: X_en = 1; X_dir = 0; bDir_X_label.Draw("Droite (dir:%d)",X_dir); break; case 2: X_en = 0; bDir_X_label.Draw("Pause",0); break; } } if (FourcheLibre){ bStart.Draw("Ready",0); if (Y_en){ Steppers_Y.enable(); Steppers_Y.step(Y_dir,Y_speed); Y_count++ ; } else { Steppers_Y.disable(); Y_count = 0; } if ((X_en) && (X_count < 4000)){ Stepper_X.enable(); Stepper_X.step(X_dir,X_speed); X_count++ ; } else { Stepper_X.disable(); X_count = 0; } } else { Steppers_Y.disable(); Stepper_X.disable(); bStart.Draw("Fourche !",0); } bCount_X_label.Draw("Count : %d",X_count); bCount_Y_label.Draw("Count : %d",Y_count); } }