scottbez1 / smartknob

Haptic input knob with software-defined endstops and virtual detents
https://www.youtube.com/watch?v=ip641WmY4pA
Other
19k stars 1.09k forks source link

Help - Firmware flashing #76

Open bulior opened 2 years ago

bulior commented 2 years ago

Can anyone help me to flash the firmware, especially the display. The documentation is still in progress. I tryed to upload with VS Code and PlatformIO but the board is in boot loop.

With my test code to check the DMS it is possible to run the system:

/*
  Name:    Smartknob_test.ino
  Created: 5/19/2022 11:51:51 PM
  Author:  bulior
*/

//  LED´s
#include <FastLED.h>
#define NUM_LEDS 8
#define PIN_LED_DATA = 7

//  Note: Allowed to use pin 7 in FastLED lib
//  #define FASTLED_UNUSABLE_PIN_MASK (0ULL | _FL_BIT(6) | _FL_BIT(8) | _FL_BIT(9) | _FL_BIT(10) | _FL_BIT(20))
CRGB leds[NUM_LEDS];

//
//using namespace std;
//#include <algorithm>
#include <HX711.h>
HX711 scale;
uint8_t dataPin = 38;
uint8_t clockPin = 2;
long press_value_unit;

float hue;

//Display
//#include "roboto_light_60.h"

// the setup function runs once when you press reset or power the board
void setup() {
  delay(250);
  Serial.begin(19200);
  Serial.println("Smart Knob BEN 2022-04-23");

  FastLED.addLeds<SK6812, 7, GRB>(leds, NUM_LEDS);  //  LEDs
  for (int i = 0; i < NUM_LEDS; i++) {
    leds[i] = CRGB::Blue;
  }
  FastLED.setBrightness(50);
  FastLED.show();

  scale.begin(dataPin, clockPin);                   //  DMS

}

// the loop function runs over and over again until power down or reset
void loop() {
  //Serial.println("LED");
  delay(50);
  hx711read();

}

void hx711read() {
  const int32_t lower = -950000;
  const int32_t upper = -360000;

  if (scale.wait_ready_timeout(50)) {
    int32_t reading = scale.read();
    Serial.println(reading);
    // Ignore readings that are way out of expected bounds
    if (reading >= lower - (upper - lower) && reading < upper + (upper - lower) * 2) {
      static uint32_t last_reading_display;
      if (millis() - last_reading_display > 1000) {
        Serial.print("HX711 reading: ");
        Serial.println(reading);
        last_reading_display = millis();
      }
      long value = constrain(reading, lower, upper);
      Serial.print("Wert: ");
      Serial.print(value);
      press_value_unit = 1. * (value - lower) / (upper - lower);
      Serial.print(" / ");
      Serial.print(press_value_unit);
      hue = (value-upper)*-1.00;
      hue = hue/586000.00;
      hue = hue*255.00;
      Serial.print(" / ");
      Serial.println(hue);

      for (int i = 0; i < NUM_LEDS; i++) {
        leds[i] = CHSV(hue, 255, 255);
      }
      FastLED.show();

    }
  }
  else {
    Serial.println("HX711 not found.");

    for (uint8_t i = 0; i < NUM_LEDS; i++) {
      leds[i] = CRGB::Green;
    }
    FastLED.show();

  }
}
AR17HY commented 2 years ago

You should be able to get out of boot loop by using the boot push button on the esp32 board :

  1. press BOOT switch (maintain it)
  2. press EN switch (and release it)
  3. wait 1 sec and release the boot switch You should be able to access the MCU through the UART/USB port (seen as COM port on your windows machine) and flashing must be all right.

If it does not work : Can you share the platformio.ini ? What OS are you running VSC ? Can you confirm the hardware you are using ? (esp32 version and USB driver)

scottbez1 commented 2 years ago

Can you share the debug output from the boot loop when you use Upload and Monitor? That will help pin down exactly what's happening. One known issue is that you'll get a bootloop if you don't have the VEML7700 ALS sensor - the I2C initialization causes a bootloop if it's not present. So if the error message is related to I2C, I'd recommend turning off SK_ALS and try again. Otherwise, hopefully sharing the log output will help identify the issue.

alex934 commented 1 year ago

You should be able to get out of boot loop by using the boot push button on the esp32 board :

  1. press BOOT switch (maintain it)
  2. press EN switch (and release it)
  3. wait 1 sec and release the boot switch You should be able to access the MCU through the UART/USB port (seen as COM port on your windows machine) and flashing must be all right.

What push buttons are you referring to? There are no push buttonss on the T-micro 32

image
bulior commented 1 year ago

Okay thanks i fix the boot loop by resoldering and i'm able to flash my firmware.

But if i try to flash your general firmware i will have some issues. I implemented your files as project in Visual Studio Code and compiled with [env:view] profile. All librarys has been downloaded but i will get lots of error messages.

In smartknob.pb.h the header pb.h cant be find. I added Nanopb to the librarys and it works but then the next lib is missing. Which libs have i add manually ?

It seams that this vars are not declaired:

After defininging them to