Ciao ragazzi ho un problema. Dovrei convertire questo in java:
codice:#ifndef KEYPAD_H #define KEYPAD_H #include "utility/Key.h" // Arduino versioning. #if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #endif // bperrybap - Thanks for a well reasoned argument and the following macro(s). // See http://arduino.cc/forum/index.php/to...tml#msg1069480 #ifndef INPUT_PULLUP #warning "Using pinMode() INPUT_PULLUP AVR emulation" #define INPUT_PULLUP 0x2 #define pinMode(_pin, _mode) _mypinMode(_pin, _mode) #define _mypinMode(_pin, _mode) \ do { \ if(_mode == INPUT_PULLUP) \ pinMode(_pin, INPUT); \ digitalWrite(_pin, 1); \ if(_mode != INPUT_PULLUP) \ pinMode(_pin, _mode); \ }while(0) #endif #define OPEN LOW #define CLOSED HIGH typedef char KeypadEvent; typedef unsigned int uint; typedef unsigned long ulong; // Made changes according to this post http://arduino.cc/forum/index.php?topic=58337.0 // by Nick Gammon. Thanks for the input Nick. It actually saved 78 bytes for me. :) typedef struct { byte rows; byte columns; } KeypadSize; #define LIST_MAX 10 // Max number of keys on the active list. #define MAPSIZE 10 // MAPSIZE is the number of rows (times 16 columns) #define makeKeymap(x) ((char*)x) //class Keypad : public Key, public HAL_obj { class Keypad : public Key { public: Keypad(char *userKeymap, byte *row, byte *col, byte numRows, byte numCols); virtual void pin_mode(byte pinNum, byte mode) { pinMode(pinNum, mode); } virtual void pin_write(byte pinNum, boolean level) { digitalWrite(pinNum, level); } virtual int pin_read(byte pinNum) { return digitalRead(pinNum); } uint bitMap[MAPSIZE]; // 10 row x 16 column array of bits. Except Due which has 32 columns. Key key[LIST_MAX]; unsigned long holdTimer; char getKey(); bool getKeys(); KeyState getState(); void begin(char *userKeymap); bool isPressed(char keyChar); void setDebounceTime(uint); void setHoldTime(uint); void addEventListener(void (*listener)(char)); int findInList(char keyChar); int findInList(int keyCode); char waitForKey(); bool keyStateChanged(); byte numKeys(); private: unsigned long startTime; char *keymap; byte *rowPins; byte *columnPins; KeypadSize sizeKpd; uint debounceTime; uint holdTime; void scanKeys(); bool updateList(); void nextKeyState(byte n, boolean button); void transitionTo(byte n, KeyState nextState); void (*keypadEventListener)(char); }; #endif



