Skip to content
This repository has been archived by the owner on Aug 14, 2022. It is now read-only.

Commit

Permalink
Touch bar rotation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
203Null committed Dec 10, 2020
1 parent 610c594 commit 12cfdf6
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 110 deletions.
10 changes: 10 additions & 0 deletions Matrix.ino
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,20 @@ if (Touch.scan())
break;
if (Touch.getKey(Touch.changelist[i]).state == PRESSED)
{
#ifdef DEBUG
CompositeSerial.print("Touch Key #");
CompositeSerial.print(Touch.changelist[i]);
CompositeSerial.println(" Pressed");
#endif
Midi.sendNoteOn(0, touch_keymap[current_keymap][Touch.changelist[i]], Touch.getKey(Touch.changelist[i]).velocity * 127);
}
else if (Touch.getKey(Touch.changelist[i]).state == RELEASED)
{
#ifdef DEBUG
CompositeSerial.print("Touch Key #");
CompositeSerial.print(Touch.changelist[i]);
CompositeSerial.println(" Released");
#endif
Midi.sendNoteOff(0, touch_keymap[current_keymap][Touch.changelist[i]], 0);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Bootanimation/KaskobiBoot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void UI::kaskobiWaitAnimation()
}
LED.offXY(0x07, true);
LED.update();
onPause = 2;
onPause = 0;
}
else
{
Expand All @@ -36,7 +36,7 @@ void UI::kaskobiWaitAnimation()
LED.update();
delay(10);
}
onPause = 2;
onPause = 1;
}
uiTimer.recordCurrent();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Core/EEPROM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ void setupEEPROM()

void variableLoad()
{
if(EEPROM_USER.read(E_INIT) == 0x00CB)
if(EEPROM_USER.read(E_INIT) == 0x00CB) //EEPROM was just reseted
{
saveAllSetting();
return;
}

if(EEPROM_USER.read(E_INIT) != 0x0203)
if(EEPROM_USER.read(E_INIT) != 0x0203) //EEPROM isn't ready
{
initEEPROM();
return;
Expand Down
71 changes: 13 additions & 58 deletions src/Core/MatrixSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,39 +568,14 @@ u8 xytoy(u8 xy)
return xy & 0x0F;
}

u8 xyRotation(u8 xy)
{
u8 x = (xy & 0xF0) >> 4;
u8 y = xy & 0x0F;
u8 xr;
u8 yr;
switch (rotation)
{
case 1:
xr = y;
yr = 7 - x;
break;
case 2:
xr = 7 - x;
yr = 7 - y;
break;
case 3:
xr = 7 - y;
yr = x;
break;
default:
xr = x;
yr = y;
}
return xr * 0x10 + yr;
}

u8 xyRotation(u8 xy, u8 r)
u8 xyRotation(u8 xy, u8 r /*= 255*/)
{
u8 x = (xy & 0xF0) >> 4;
u8 y = xy & 0x0F;
u8 xr;
u8 yr;
if(r = 255)
r = rotation;
switch (r)
{
case 1:
Expand All @@ -622,39 +597,14 @@ u8 xyRotation(u8 xy, u8 r)
return xr * 0x10 + yr;
}

u8 xyReverseRotation(u8 xy)
{
u8 x = (xy & 0xF0) >> 4;
u8 y = xy & 0x0F;
u8 xr;
u8 yr;
switch (rotation)
{
case 1:
xr = 7 - y;
yr = x;
break;
case 2:
xr = 7 - x;
yr = 7 - y;
break;
case 3:
xr = y;
yr = 7 - x;
break;
default:
xr = x;
yr = y;
}
return xr * 0x10 + yr;
}

u8 xyReverseRotation(u8 xy, u8 r)
u8 xyReverseRotation(u8 xy, u8 r /*= 255*/)
{
u8 x = (xy & 0xF0) >> 4;
u8 y = xy & 0x0F;
u8 xr;
u8 yr;
if(r = 255)
r = rotation;
switch (r)
{
case 1:
Expand All @@ -681,14 +631,19 @@ u8 touchbarRotation(u8 id)
switch (rotation)
{
case 0:
case 1:
case 3:
return id;
case 1:
case 2:
case 3:
return 7 - id;
}
}

u8 touchbarReverseRotation(u8 id)
{
return touchbarRotation(id);
}

void recordReportCode(u8 code)
{
#ifdef DEBUG
Expand Down
7 changes: 3 additions & 4 deletions src/Core/MatrixSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ u8 xytoxy(u8 x, u8 y);
u8 xytox(u8 xy);
u8 xytoy(u8 xy);
//u8 xyToIndex(u8 X,u8 Y);
u8 xyRotation(u8 xy);
u8 xyRotation(u8 xy, u8 r);
u8 xyReverseRotation(u8 xy);
u8 xyReverseRotation(u8 xy, u8 r);
u8 xyRotation(u8 xy, u8 r = 255);
u8 xyReverseRotation(u8 xy, u8 r = 255);
u8 touchbarRotation(u8 id);
u8 touchbarReverseRotation(u8 id);
void recordReportCode(u8 code);
//u16 velocityCurve(u16 input);

Expand Down
40 changes: 20 additions & 20 deletions src/HAL/LED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ void LED::setWRGB(s16 index, u8 w, u8 r, u8 g, u8 b, bool overlay /*= false*/)

void LED::setCRGB(s16 index, CRGB CRGB, bool overlay /*= false*/, bool gamma /*= false*/)
{
#ifdef DEBUG
CompositeSerial.print("LED\t");
CompositeSerial.print(index);
CompositeSerial.print("\t");
CompositeSerial.print(CRGB.r);
CompositeSerial.print("\t");
CompositeSerial.print(CRGB.g);
CompositeSerial.print("\t");
CompositeSerial.println(CRGB.b);
#endif
// #ifdef DEBUG
// CompositeSerial.print("LED\t");
// CompositeSerial.print(index);
// CompositeSerial.print("\t");
// CompositeSerial.print(CRGB.r);
// CompositeSerial.print("\t");
// CompositeSerial.print(CRGB.g);
// CompositeSerial.print("\t");
// CompositeSerial.println(CRGB.b);
// #endif

if(index < 0)
return;
Expand Down Expand Up @@ -228,16 +228,16 @@ void LED::setXYWRGB(u8 xy, u8 w, u8 r, u8 g, u8 b, bool overlay /*= false*/)

void LED::setXYCRGB(u8 xy, CRGB CRGB, bool overlay /*= false*/, bool gamma /*= false*/)
{
#ifdef DEBUG
CompositeSerial.print("LED XY\t");
CompositeSerial.print(xy, HEX);
CompositeSerial.print("\t");
CompositeSerial.print(CRGB.r);
CompositeSerial.print("\t");
CompositeSerial.print(CRGB.g);
CompositeSerial.print("\t");
CompositeSerial.println(CRGB.b);
#endif
// #ifdef DEBUG
// CompositeSerial.print("LED XY\t");
// CompositeSerial.print(xy, HEX);
// CompositeSerial.print("\t");
// CompositeSerial.print(CRGB.r);
// CompositeSerial.print("\t");
// CompositeSerial.print(CRGB.g);
// CompositeSerial.print("\t");
// CompositeSerial.println(CRGB.b);
// #endif

CRGB = compileColor(CRGB, gamma);

Expand Down
42 changes: 21 additions & 21 deletions src/HAL/Touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ bool Touch::scanType1() //TTP229-BSD (16Keys merged to 8Keys)

if(changed)
{
#ifdef DEBUG
// filler = 0;
// CompositeSerial.print("filler: ");
// CompositeSerial.println(filler);
CompositeSerial.print("Touch Action Raw ");
for (u8 x = 0; x < 16; x++)
{
CompositeSerial.print(newInput[x]);
CompositeSerial.print(" ");
}
CompositeSerial.println();
#endif
// #ifdef DEBUG
// // filler = 0;
// // CompositeSerial.print("filler: ");
// // CompositeSerial.println(filler);
// CompositeSerial.print("Touch Action Raw ");
// for (u8 x = 0; x < 16; x++)
// {
// CompositeSerial.print(newInput[x]);
// CompositeSerial.print(" ");
// }
// CompositeSerial.println();
// #endif

for (u8 x = 0; x < 16; x+=2)
{
Expand All @@ -90,14 +90,14 @@ bool Touch::scanType1() //TTP229-BSD (16Keys merged to 8Keys)
{
if(!Touch::addtoList(index))
return changed;
#ifdef DEBUG
CompositeSerial.print("Touch Action ");
CompositeSerial.print(index);
CompositeSerial.print(" ");
CompositeSerial.print(KeyStatesString[touchState[index].state]);
CompositeSerial.print(" ");
CompositeSerial.println(touchState[index].velocity);
#endif
// #ifdef DEBUG
// CompositeSerial.print("Touch Action ");
// CompositeSerial.print(index);
// CompositeSerial.print(" ");
// CompositeSerial.print(KeyStatesString[touchState[index].state]);
// CompositeSerial.print(" ");
// CompositeSerial.println(touchState[index].velocity);
// #endif
}
else
{
Expand Down Expand Up @@ -193,7 +193,7 @@ KeyInfo Touch::updateKey(KeyInfo currentKey, float input)

KeyInfo Touch::getKey(u8 index)
{
return touchState[index];
return touchState[touchbarReverseRotation(index)];
}

float Touch::calculatePercentage()
Expand Down
4 changes: 2 additions & 2 deletions src/Parameter/MatrixParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ typedef volatile const int64_t vsc64;
const u8 SYSEXID[3] = {0x00, 0x02, 0x03};

#define EEPROMVERSION 1 //Each EEPROM change will cause this to increase
#define FWVERSION_STRING "0.8.0 beta 6" //String(MAJOR_VER)+ "." +MINOR_VER+"." +PATCH_VER+(BUILD_VER == 0)?"":("b"+BUILD_VER)
#define FWVERSION_STRING "0.8.0 beta 7" //String(MAJOR_VER)+ "." +MINOR_VER+"." +PATCH_VER+(BUILD_VER == 0)?"":("b"+BUILD_VER)
#define MAJOR_VER 0
#define MINOR_VER 8
#define PATCH_VER 0
#define BUILD_VER 6 //0 for Release, any other number will repensent beta ver
#define BUILD_VER 7 //0 for Release, any other number will repensent beta ver

#define BOOTLOADER_VERSION *(u32 *)(0x08001E00)
#define MATRIX_MODEL *(u32 *)(0x08001E04)
Expand Down
2 changes: 1 addition & 1 deletion src/Parameter/MatrixVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern u32 led_color_temperture = 0xFFFFFFFF;
extern bool desaturated_mode = false;
extern u8 desaturate_rate = 80; // 0~255
extern u8 fps = 60;
extern u16 fps_micros = 1000 / fps;
extern u16 fps_micros = 1000 / fps; //Well I just realize that it's still mill not micro. TODO

extern u8 keypad_scanrate = 120;
extern u16 keypad_scanrate_micros = 1000 / keypad_scanrate;
Expand Down

0 comments on commit 12cfdf6

Please sign in to comment.