AILIFE4798 / Hoverboard-Firmware-Hack-Gen2.x-MM32

A firmware to control split motherboard hoverboards with UART
MIT License
19 stars 6 forks source link

sending new config (incuding new SLAVE_ID) from ESP32 to hoverboard EEPROM.. #12

Open RoboDurden opened 7 months ago

RoboDurden commented 7 months ago

@AILIFE4798 , i have begun to implement the SerialServer2HoverConfig struct you already imported with remoteUartBus.c

                case 2: 
                {
                    SerialServer2HoverConfig* pData = (SerialServer2HoverConfig*) aReceiveBuffer;
                    if (    (pData->fBatteryVoltage > 0) && (pData->fBatteryVoltage < 60.0) )
                    {
                        BAT_FULL = pData->fBatteryVoltage;
                        BAT_EMPTY = BAT_FULL / 4.2 * 2.7;
                    }
                    if (pData->iDivemode <= SINE_SPEED)
                        DRIVEMODE = pData->iDivemode;
                    if (pData->iSlaveNew >= 0)
                        SLAVE_ID = pData->iSlaveNew;

                    EEPROM_Write((u8*)pinstorage, 2 * 64);    //if the detection failed, the pin is still saved
                    break;
                }

Maybe you want to add a slaveId-reset when the user pushes the onOff button 7 times within in the first 7 seconds to reset the slaveId to 1.. Then no Keil woud be needed to program the singe boards..

I would like this feature for the youtube tutorial to switch the different drive modes from the TestSpeed.ino. So without recompling the main binary.

Update: the 7 button pushes to reset are not really needed. User can send new slave id to all possible 64 ids and all boards connected to the uartbus will reset to the new slaveID.

RoboDurden commented 7 months ago

LED_BUILTIN is about my autodetect ? I think it is still there: case 'p': iFound = SCAN_ONBOARD_LED; break;

It is still from the old Gen2.0 that in defines.h this led is called

// Mosfet output, little onboard led
#define MOSFET_OUT  TODO_PIN    // robo might be the blue led inside the hover motors

And it is still in use:

        #ifdef MOSFET_OUT
            digitalWrite(MOSFET_OUT,    (steerCounter%200) < 100    );  // onboard led blinking :-)
        #endif

I have not added control onBoardLed from ESP32:

uint8_t wState = 1; // 1=ledGreen, 2=ledOrange, 4=ledRed, 8=ledUp, 16=ledDown , 32=Battery3Led, 64=Disable, 128=ShutOff

Idea was that the onboard led is only to reflect if the system is working correctly. Maybe blinking error codes.

RoboDurden commented 7 months ago

My 30 minutes "full walkthrough" is online: https://youtu.be/wUR05iwLMtM I first intented to remove everything about my newSlaveId because i by now also think that it is better to run pinFinder for every new board installed. But it was the only refence to setting a config only for one slave like 1 si 2, so i did not cut it. And the topic might generate a few comments, which is good to promote your work.

Took me several hours to do this video, i would have prefered if you had done it. But i am happy to help :-)

I-hate-2FA commented 7 months ago

@RoboDurden i mean the code for esp image i need to add #define LED_BUILTIN 22

RoboDurden commented 7 months ago

Ah that .. some boards have this defined by default, some dev boards not and it needs manual adding like with the board that you use.