Facebook
From Reliable Meerkat, 4 Years ago, written in Plain Text.
This paste is a reply to Kod from Damian - go back
Embed
Viewing differences between Kod and Re: Kod
#include "U8glib.h"
#include "M2tk.h"
#include "m2ghu8g.h"
#define step_pin 26
EN 23 
#define dir_pin 28
RW 17
#define enable_pin 24



RS 16


// U8g setup
U8GLIB_ST7920_128X64_1X lcd(EN, RW, RS);                  // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9

// DOGM132, DOGM128 and DOGXL160 shield
uint8_t uiKeyUpPin = 33;         
uint8_t uiKeyBackPin = 31;
uint8_t uiKeySelectPin = 35;
uint8_t u;     /* the number, which was entered by the user */
float srednica1;
float srednica2;
void fn_ok(m2_el_fnarg_p fnarg) {
  /* do something with the number */
}

M2_LABEL(el_goto_title, NULL, "Wybierz srednice");
M2_LABEL(el_goto_title2, NULL, "filamenu:");
M2_ROOT(el_goto_part1, NULL, "1.75", &srednica1);
M2_ROOT(el_goto_part2, NULL, "2.85", &srednica2);
M2_LIST(list_menu) = {&el_goto_title,&el_goto_title2, &el_goto_part1, &el_goto_part2,};
M2_VLIST(el_menu_vlist, NULL, list_menu);
M2_ALIGN(el_top, "W64H64", &el_menu_vlist);
M2tk m2(&el_top, m2_es_arduino, m2_eh_4bs, m2_gh_u8g_bfs);

void draw(void) {
    m2.draw();
}

// Arduino setup procedure (called only once)
void setup() {
  // put your setup code here, Connect u8glib with m2tklib
  m2_SetU8g(lcd.getU8g(), m2_u8g_box_icon);

  // Assign u8g font 
to run once:
 pinMode(dir_pin, OUTPUT);
  pinMode(step_pin, OUTPUT);
  pinMode(enable_pin, OUTPUT);
  digitalWrite(dir_pin, LOW);
  digitalWrite(enable_pin, LOW);
}





index 0
  m2.setFont(0, u8g_font_7x13);
  // Setup keys
  m2.setPin(M2_KEY_SELECT, uiKeySelectPin);
  m2.setPin(M2_KEY_NEXT, uiKeyUpPin);
  m2.setPin(M2_KEY_PREV, uiKeyBackPin);

}
void loop() {
   digitalWrite(step_pin, HIGH);\n   delayMicroseconds(1000);\n  digitalWrite(step_pin, LOW);\n  delayMicroseconds(1000);\n  m2.checkKey();
  if ( m2.handleKey() ) {
    lcd.firstPage();  
    do {
      m2.checkKey();
      draw();
    } while( lcd.nextPage() );
  }
 
}