help. J’ai besoin d’un(e) gourou de l’arduino.
Je suis entrain de tester le montage https://www.thingiverse.com/thing:2479976. Il s’agit d’un clavier permettant de faire bouger la CN a partir de boutons X+ X- Y+ …
Dans les fichiers sur le site thingiverse, il y a le programme arduino qui permet de faire fonctionner tout cela. J’ai teste et pour que ca marche, il faut que je configure mon clavier AZERTY en clavier americain. si je reste en clavier francais, lorsque j’envoie un Q, Bcnc recoit un A, si j’envoie un G90, bCNC recoit Gçà etc…, si je le passe en clavier americain G90 est bien recu par bCNC.
Est ce que quelqu’un pourrait regarder le programme arduino (ci dessous ou sur le site) et voir si vous avez une idee comment changer le clavier.
#include <Keyboard.h>
/* Buttons to USB Keyboard Example
You must select Keyboard from the "Tools > USB Type" menu
This example code is in the public domain.
*/
#include <Bounce.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Encoder.h>
Encoder myEnc(5, 6);
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
static const unsigned char PROGMEM logo16_glcd_bmp[] =
{ B00000000, B11000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B11110011, B11100000,
B11111110, B11111000,
B01111110, B11111111,
B00110011, B10011111,
B00011111, B11111100,
B00001101, B01110000,
B00011011, B10100000,
B00111111, B11100000,
B00111111, B11110000,
B01111100, B11110000,
B01110000, B01110000,
B00000000, B00110000 };
#if (SSD1306_LCDHEIGHT != 64)
//#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
long oldPosition = -999;
long newPosition = 0;
#define ARRAYSIZE 19
String step_mm_xy[ARRAYSIZE] = { "0.05", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1.0", "2.0", "5.0", "10.0", "20.0", "50.0", "100.0", "200.0", "300.0"};
String step_mm_z[ARRAYSIZE] = { "0.05", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1.0", "2.0", "3.0", "4.0", "5.0", "6.0", "7.0", "8.0", "10.0"};
String stepwidth_xy = "1.0";
String stepwidth_z = "1.0";
// Create Bounce objects for each button. The Bounce object
// automatically deals with contact chatter or "bounce", and
// it makes detecting changes very simple.
Bounce btn_y_minus = Bounce(0, 10);
Bounce btn_y_plus = Bounce(1, 10); // 10 = 10 ms debounce time
Bounce btn_z_minus = Bounce(2, 10); // which is appropriate for
Bounce btn_z_plus = Bounce(3, 10); // most mechanical pushbuttons
Bounce button4 = Bounce(4, 10);
Bounce btn_x_minus = Bounce(12, 10); // if a button is too "sensitive"
Bounce btn_x_plus = Bounce(14, 10); // to rapid touch, you can
// increase this time.
Bounce unlock_btn = Bounce(17, 10);
void setup() {
// Configure the pins for input mode with pullup resistors.
// The pushbuttons connect from each pin to ground. When
// the button is pressed, the pin reads LOW because the button
// shorts it to ground. When released, the pin reads HIGH
// because the pullup resistor connects to +5 volts inside
// the chip. LOW for "on", and HIGH for "off" may seem
// backwards, but using the on-chip pullup resistors is very
// convenient. The scheme is called "active low", and it's
// very commonly used in electronics... so much that the chip
// has built-in pullup resistors!
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP); // Teensy++ LED, may need 1k resistor pullup
pinMode(17, INPUT_PULLUP); // safety unlock button
delay(2000);
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
// init done
// Show image buffer on the display hardware.
// Since the buffer is intialized with an Adafruit splashscreen
// internally, this will display the splashscreen.
display.display();
delay(2000);
// Clear the buffer.
display.clearDisplay();
// miniature bitmap display
// display.clearDisplay();
// display.drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1);
// display.display();
// text display tests
display.setTextSize(1); // origine display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("bCNC Keyboard");
display.display();
}
void loop() {
// Update all the buttons. There should not be any long
// delays in loop(), so this runs repetitively at a rate
// faster than the buttons could be pressed and released.
btn_y_minus.update();
btn_y_plus.update();
btn_z_minus.update();
btn_z_plus.update();
button4.update();
btn_x_minus.update();
btn_x_plus.update();
unlock_btn.update();
if (unlock_btn.read() == LOW) {
// Check each button for "falling" edge.
if (btn_y_minus.fallingEdge()) {
setCommandMode();
String gcode_cmd = "G91G0Y-"+ stepwidth_xy;
Keyboard.println(gcode_cmd);
Keyboard.println("G90");
}
if (btn_y_plus.fallingEdge()) {
setCommandMode();
String gcode_cmd = "G91G0Y"+ stepwidth_xy;
Keyboard.println(gcode_cmd);
Keyboard.println("G90");
}
if (btn_z_minus.fallingEdge()) {
setCommandMode();
String gcode_cmd = "G91G0Z-"+ stepwidth_z;
Keyboard.println(gcode_cmd);
Keyboard.println("G90");
}
if (btn_z_plus.fallingEdge()) {
setCommandMode();
String gcode_cmd = "G91G0Z"+ stepwidth_z;
Keyboard.println(gcode_cmd);
Keyboard.println("G90");
}
if (button4.fallingEdge()) {
setCommandMode();
Keyboard.println("!");
// Keyboard.set_key1(KEY_TAB);
}
if (btn_x_minus.fallingEdge()) {
setCommandMode();
String gcode_cmd = "G91G0X-"+ stepwidth_xy;
Keyboard.println(gcode_cmd);
Keyboard.println("G90");
}
if (btn_x_plus.fallingEdge()) {
setCommandMode();
String gcode_cmd = "G91G0X"+ stepwidth_xy;
Keyboard.println(gcode_cmd);
Keyboard.println("G90");;
}
}
long newPosition = abs(myEnc.read());
if (newPosition != oldPosition) {
if (newPosition<0) {newPosition=0;}
if (newPosition>ARRAYSIZE*2) {newPosition=ARRAYSIZE;}
oldPosition = newPosition;
display.clearDisplay();
display.setCursor(5,10);
int arr_id = newPosition/2;
stepwidth_xy = step_mm_xy[arr_id];
display.print("XY ");
display.print(step_mm_xy[arr_id]);
display.println("mm");
// display.display();
display.setCursor(5,25); // origine display.setCursor(5,30);
arr_id = newPosition/2;
stepwidth_z = step_mm_z[arr_id];
display.print("Z ");
display.print(step_mm_z[arr_id]);
display.println("mm");
display.display();
}
}
void setCommandMode()
{
Keyboard.set_modifier(MODIFIERKEY_CTRL);
Keyboard.set_key1(KEY_SPACE);
Keyboard.send_now();
// release all the keys at the same instant
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
delay(200);
}
Merci de votre aide