Page 1 of 1

Improving existing apps, collaboration between authors

Posted: Tue Jun 01, 2021 8:02 pm
by ivo.bloechliger
Dear TWatch Team

Great site and service, many thanks.
I changed the accelerometer demoapp to restore the initial screen rotation, it's just 3 lines of additional code. Does the original author get notified of my changes, or should I just e-mail him with my additions?
Also, the orientation of the sensor seems to be different on the V3-Watch, but that's probably something I should have a look with the TWatch Library itself.

Warm regards

Ivo

Re: Improving existing apps, collaboration between authors

Posted: Tue Jun 01, 2021 8:56 pm
by mchavez
Hello,

Thanks for your kind words. We are working hard to release new functionalities and fix bugs, because we think T-Watch is a very good watch and it just needs good tools for better use. This is still a work process and we do it just for fun.

If you want, you can share your suggestions in this forum to improve our examples, and we will analyze it. Or, if you want, you can release your own version of the application with your changes and share it with all the users.

Re: Improving existing apps, collaboration between authors

Posted: Fri Jun 04, 2021 7:44 am
by ivo.bloechliger
My changes for now are just the lines containing origRotation, feel free to incorporate them into your app. I won't release it as a new app, since its nothing new.

Code: Select all

TTGOClass *__watch;
TFT_eSPI *__tft;
BMA *__sensor;
uint8_t __prevRotation;
uint8_t __origRotation;


void __show () {
    __watch = TTGOClass::getWatch();
    __tft = __watch->tft;
    __sensor = __watch->bma;
    __tft->fillScreen(TFT_BLACK);
    __tft->setTextFont(4);
    __tft->setTextColor(TFT_WHITE, TFT_BLACK);
    __origRotation = __tft->getRotation();
 }

void __hide () {
  // Restore original orientation (otherwise the clocks might get displayed not as intended)
  __tft->setRotation(__origRotation);
}

void __loop () {
    Accel acc;

    // Get acceleration data
    bool res = __sensor->getAccel(acc);

    if (res == false) {
        Serial.println("getAccel FAIL");
    } else {
        // Show the data
        __tft->fillRect(98, 100, 70, 85, TFT_BLACK);
        __tft->setCursor(80, 100);
        __tft->print("X:"); __tft->println(acc.x);
        __tft->setCursor(80, 130);
        __tft->print("Y:"); __tft->println(acc.y);
        __tft->setCursor(80, 160);
        __tft->print("Z:"); __tft->println(acc.z);
    }
    uint8_t rotation = __sensor->direction();
    if (__prevRotation != rotation) {
        __prevRotation = rotation;
        Serial.println(rotation);
        switch (rotation) {
        case DIRECTION_DISP_DOWN:
            //No use
            break;
        case DIRECTION_DISP_UP:
            //No use
            break;
        case DIRECTION_BOTTOM_EDGE:
            __tft->setRotation(2);
            break;
        case DIRECTION_TOP_EDGE:
            __tft->setRotation(0);
            break;
        case DIRECTION_RIGHT_EDGE:
            __tft->setRotation(3);
            break;
        case DIRECTION_LEFT_EDGE:
            __tft->setRotation(1);
            break;
        default:
            break;
        }
      __tft->fillScreen(TFT_BLACK);
    }
    delay(500);
}

Re: Improving existing apps, collaboration between authors

Posted: Sat Jun 05, 2021 5:11 pm
by mchavez
Thank you, we added your code suggestion to restore the original rotation when the app exists 8-)