Hi.
Since I got my ks0108 display working with openGLCD with my teensy 3.1 I've started to try to make a ui to control a stepper motor and ir-led to trigger a camer(panoramic photo shooter/photogramitry rig).
I found m2tklib and it seemed nice. Got a few things working. Like displaying lists and updating parameters like, turning speed, shots per revolution and so on, from buttons.
First issue:
I also wanted a progress bar when the rig is shooting photos. Since i didnt find any element in m2tk I tried to use low level graphics to produce the progress bar. All turned out ok except that the screen is flickering when changing a value or navigating between the inputs in the lists. Searched through the library and found that m2tklib uses GLCD.ClearScreen() when drawing(which i dont when I update my progress bar). How do I solve the flickering?
Second issue:
In the same sketch I want to start and stop the photo function some how and tried to use M2_TOGGLE to change the criteria to start the photo function. Navigating through lists and updating the other parameters work fine but when I toggle the M2_TOGGLE my application hangs/freezes.
This is what I came up with. I dont have the actual functions to control the motor and the camera implemented yet:
#include <openGLCD.h>
#include <multiCameraIrControl.h>
#include "M2tk.h"
#include "utility/m2ghopenglcd.h"
#include "fonts/System5x7.h"
//button pins
uint8_t uiKeyDownPin = 10;
uint8_t uiKeyNextPin = 11;
uint8_t uiKeyPrevPin = 12;
uint8_t uiKeyUpPin = 15;
uint8_t uiKeySelectPin = 14;
//settings
uint32_t microStepping = 0;
uint32_t shotsPerSweep = 0;
uint32_t shutterSpeed = 0;
uint8_t* shoot = 0;
uint8_t shoot2;
uint8_t progbar = 50;
uint32_t lastTime = 0;
boolean up = true;
void fn_ok(m2_el_fnarg_p fnarg){
}
// initialize list items
M2_LABEL(micro_stepping, "f0", "Micro stepping");
M2_U32NUM(el_micro_stepping, "a1c2", µStepping);
M2_LABEL(shots_per_sweep, "f0", "Shots/sweep");
M2_U32NUM(el_shots_per_sweep, "a1c3", &shotsPerSweep);
M2_LABEL(shutter_speed, "f0", "Shutter speed");
M2_U32NUM(el_shutter_speed, "a1c3", &shutterSpeed);
M2_LABEL(shoot_sweep, "f0", "Shoot sweep");
M2_TOGGLE(el_shoot, "f0", shoot);
M2_BUTTON(el_ok, "", "ok", fn_ok);
M2_LIST(list) = {
µ_stepping, &el_micro_stepping,
&shots_per_sweep, &el_shots_per_sweep,
&shutter_speed, &el_shots_per_sweep,
&shoot_sweep, &el_shoot
};
M2_GRIDLIST(list_element, "c2", list);
M2tk m2(&list_element, m2_es_arduino, m2_eh_2bs, m2_gh_openglcd_ffs);
void setup(){
m2.setPin(M2_KEY_SELECT, uiKeySelectPin);
m2.setPin(M2_KEY_NEXT, uiKeyNextPin);
Serial.begin(9600);
m2.setFont(0, System5x7);
}
void loop(){
m2.checkKey();
if(m2.handleKey()){
m2.draw();
}
//update progress bar, for progress bar test/debug.
if((millis() - lastTime) > 200){
lastTime = millis();
if(up){progbar++;}
if(progbar==100){up=false;}
if(!up){progbar--;}
if(progbar==0){up=true;}
progressBar(1,1,126,8,progbar);
}
}
void progressBar(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t progress){
//create boarder progressbar
//draw progressbar box
GLCD.DrawRect(x,y,w,h);
//clear old progress
GLCD.FillRect(x+2,y+2,w-4,h-4,PIXEL_OFF);
//draw progress
GLCD.FillRect(x+2,y+2,map(progress,0,100,0,w-2),h-4);
}
Later on i would like to change the layout a bit, but I read, somewhere on the forum, that openGLCD and m2tklib uses different coordinatesystems.
Also Im a noob at programming, still learning though
Thanks in advance.