Welcome! Log In Create A New Profile

Advanced

uiconfig sets about keys

Posted by panxinlong7373 
uiconfig sets about keys
March 16, 2013 11:18AM
Repetier, Hello!
I get lost in the button configuration (uiconfig.h). I want to map the pin to my hardware, how to set up it?( Hardware:GEN7+I2C BUS+ MCP23017 PB0-PB7 connection with eight buttons)
there are part of your firmware,I am not know clear.confused smiley
void ui_check_keys (int & action) {
# if UI_HAS_KEYS! = 0

 / / UI_KEYS_CLICKENCODER_LOW_REV (33,31); / / click encoder on pins 47 and 45. Phase is connected with gnd for signals.
 UI_KEYS_BUTTON_LOW (4, UI_ACTION_OK); / / push button, connects gnd to pin
 UI_KEYS_BUTTON_LOW (5, UI_ACTION_NEXT); / / push button, connects gnd to pin
 UI_KEYS_BUTTON_LOW (6, UI_ACTION_PREVIOUS); / / push button, connects gnd to pin
 UI_KEYS_BUTTON_LOW (11, UI_ACTION_BACK); / / push button, connects gnd to pin
 UI_KEYS_BUTTON_LOW (42, UI_ACTION_SD_PRINT); / / push button, connects gnd to pin
/ / UI_KEYS_CLICKENCODER_LOW_REV (47,45); / / click encoder on pins 47 and 45. Phase is connected with gnd for signals.
/ / UI_KEYS_BUTTON_LOW (43, UI_ACTION_OK); / / push button, connects gnd to pin
# endif
}
Best Regards
Pan Xinlong
Re: uiconfig sets about keys
March 17, 2013 06:53PM
If you are using a MCP you need a different approach. Everything goes over the I2C driver. Here a sample setting for the Adafruit RGB using the same chipset.
#define UI_HAS_KEYS 1
#define UI_HAS_BACK_KEY 1
#define UI_DISPLAY_TYPE 3
#define UI_DISPLAY_CHARSET 1
#define UI_COLS 16
#define UI_ROWS 2
#define UI_DISPLAY_I2C_CHIPTYPE 1
#define UI_DISPLAY_I2C_ADDRESS 0x40
#define UI_DISPLAY_I2C_OUTPUT_PINS 65504
#define UI_DISPLAY_I2C_OUTPUT_START_MASK 0
#define UI_DISPLAY_I2C_PULLUP 31
#define UI_I2C_CLOCKSPEED 400000L
#define UI_DISPLAY_RS_PIN _BV(15)
#define UI_DISPLAY_RW_PIN _BV(14)
#define UI_DISPLAY_ENABLE_PIN _BV(13)
#define UI_DISPLAY_D0_PIN _BV(12)
#define UI_DISPLAY_D1_PIN _BV(11)
#define UI_DISPLAY_D2_PIN _BV(10)
#define UI_DISPLAY_D3_PIN _BV(9)
#define UI_DISPLAY_D4_PIN _BV(12)
#define UI_DISPLAY_D5_PIN _BV(11)
#define UI_DISPLAY_D6_PIN _BV(10)
#define UI_DISPLAY_D7_PIN _BV(9)
#define UI_INVERT_MENU_DIRECTION true
#define UI_HAS_I2C_KEYS
#define UI_HAS_I2C_ENCODER 0
#define UI_I2C_KEY_ADDRESS 0x40

void ui_init_keys() {}
void ui_check_keys(int &action) {}
inline void ui_check_slow_encoder() {
  i2c_start_wait(UI_DISPLAY_I2C_ADDRESS+I2C_WRITE);
  i2c_write(0x12); // GIOA
  i2c_stop();
  i2c_start_wait(UI_DISPLAY_I2C_ADDRESS+I2C_READ);
  unsigned int keymask = i2c_readAck();
  keymask = keymask + (i2c_readNak()<<8);
  i2c_stop();
}
void ui_check_slow_keys(int &action) {
  i2c_start_wait(UI_DISPLAY_I2C_ADDRESS+I2C_WRITE);
  i2c_write(0x12); // GPIOA
  i2c_stop();
  i2c_start_wait(UI_DISPLAY_I2C_ADDRESS+I2C_READ);
  unsigned int keymask = i2c_readAck();
  keymask = keymask + (i2c_readNak()<<8);
  i2c_stop();
  UI_KEYS_I2C_BUTTON_LOW(4,UI_ACTION_PREVIOUS); // Up button
  UI_KEYS_I2C_BUTTON_LOW(8,UI_ACTION_NEXT); // down button
  UI_KEYS_I2C_BUTTON_LOW(16,UI_ACTION_BACK); // left button
  UI_KEYS_I2C_BUTTON_LOW(2,UI_ACTION_OK); // right button
  UI_KEYS_I2C_BUTTON_LOW(1,UI_ACTION_MENU_QUICKSETTINGS);  //Select button
}

At the end you see the keys have the valies 1,2,4,8,16,32,64,128 if you have all 8 inputs used. In that case you have also to set
#define UI_DISPLAY_I2C_OUTPUT_PINS 65280
#define UI_DISPLAY_I2C_OUTPUT_START_MASK 0
#define UI_DISPLAY_I2C_PULLUP 255

at least if the keys are on the same 8 bit, otherwise multipls PULLUP with 256 and set OUTPUT_PINS to 255.
Adjust the rest according to your hardware, but I hope you understand what you need to do.

If the firmware hangs you have used the wrong i2c address. Addresses are 2 times the official address for the firmware!


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Re: uiconfig sets about keys
March 23, 2013 01:56AM
Thanks for your help, but there are some problems struggle me.
When the LCD2004 code add into the firmware, the host will can not connect to the slave board (atmega1284P), and the LCD do not run.
Board:GEN7 V1.5-(20M)
hardware connection: I2CBUS-(1284P) PC0-16-SCL,PC1-17-SDA I2C chip:MCP23017
MCP23017-LCD2004(HD44780 controller):GPIOA(0~6) GPIOA0-RS,GPIOA1-R/W,GPIOA2-E,GPIOA3-D4,GPIOA4-D5,GPIOA5-D6,GPIOA6-D7
Settings:
#define FEATURE_CONTROLLER 1
#define UI_DISPLAY_CHARSET 1
#define UI_DISPLAY_TYPE 3
#define UI_COLS 20
#define UI_ROWS 4
#define UI_DISPLAY_I2C_CHIPTYPE 1
#define UI_DISPLAY_I2C_ADDRESS 0x40 //////////********I tested 0x40,0x70,0x80; A1=GND,A2=GND,A3=GND
#define UI_DISPLAY_I2C_OUTPUT_PINS 65504
#define UI_DISPLAY_I2C_OUTPUT_START_MASK 0
#define UI_DISPLAY_I2C_PULLUP 31
#define UI_I2C_CLOCKSPEED 100000L
#if UI_DISPLAY_TYPE==3
#define UI_DISPLAY_RS_PIN _BV(0)
#define UI_DISPLAY_RW_PIN _BV(1)
#define UI_DISPLAY_ENABLE_PIN _BV(2)
#define UI_DISPLAY_D0_PIN _BV(3)
#define UI_DISPLAY_D1_PIN _BV(4)
#define UI_DISPLAY_D2_PIN _BV(5)
#define UI_DISPLAY_D3_PIN _BV(6)
#define UI_DISPLAY_D4_PIN _BV(3)
#define UI_DISPLAY_D5_PIN _BV(4)
#define UI_DISPLAY_D6_PIN _BV(5)
#define UI_DISPLAY_D7_PIN _BV(6)
#else
....
#endif
#define UI_HAS_KEYS 0
Is there any wrong in settings?

The compile result ok .

When I delete the LCD code(#define FEATURE_CONTROLLER 0), the firmware works perfect(include the SD card).
Grateful your help!


My world is not lightly give up!
[www.pibot.com] PiBot
PiBot machine and electronic
Attachments:
open | download - Repetier_host_problem.jpg (93.6 KB)
open | download - Arduino_compile.jpg (45.1 KB)
Re: uiconfig sets about keys
March 23, 2013 03:45AM
You didn't read the end of my last post:

At the end you see the keys have the valies 1,2,4,8,16,32,64,128 if you have all 8 inputs used. In that case you have also to set
#define UI_DISPLAY_I2C_OUTPUT_PINS 65280
#define UI_DISPLAY_I2C_OUTPUT_START_MASK 0
#define UI_DISPLAY_I2C_PULLUP 255

at least if the keys are on the same 8 bit, otherwise multipls PULLUP with 256 and set OUTPUT_PINS to 255.
Adjust the rest according to your hardware, but I hope you understand what you need to do.

I also guess your config is in the wrong place. The FEATURE_CONTROLLER setting must be in Configuration.h and the rest has to be changed in uiconfig.h. Adding it in configuration will not work. It gets overwritten by the default uiconfig.h


Repetier-Software - the home of Repetier-Host (Windows, Linux and Mac OS X) and Repetier-Firmware.
Repetier-Server - the solution to control your printer from everywhere.
Visit us on Facebook and Twitter!
Re: uiconfig sets about keys
March 23, 2013 05:36AM
the FEATURE_CONTROLLER is in Configuration.h, I just show you the display type. I have been setted #define UI_HAS_KEYS 0. In this case,do the key's settings related to the firmware?
"At the end you see the keys have the valies 1,2,4,8,16,32,64,128 if you have all 8 inputs used. In that case you have also to set
#define UI_DISPLAY_I2C_OUTPUT_PINS 65280
#define UI_DISPLAY_I2C_OUTPUT_START_MASK 0
#define UI_DISPLAY_I2C_PULLUP 255 "
I have been tried these settings, unfortunately, it do not work. The result of these key's settings only let the firmware's compiled code reach to 95K.
thank you very much!
Sorry, only registered users may post in this forum.

Click here to login