weiminshen99 / GD32-hover-master-slave

5 stars 3 forks source link

Added this repo to my online compiler :-) Please add an Arduino example :-) #2

Closed RoboDurden closed 1 year ago

RoboDurden commented 1 year ago

Thank you very much for creating the makefile. So i have added this repo to my online compiler: https://pionierland.de/hoverhack/

Would be nice if you could add a simple arduino example as this firmware needs 19200 baud serial communicatoin to control it.

Simple one liner to vary speed from -300 to +300:

void loop()
{
  unsigned long iNow = millis();
  digitalWrite(LED_BUILTIN, (iNow%2000) < 500);

  int iSpeed = 3 * (ABS( (int)((iNow/20+200) % 400) - 200) - 100);   // repeats from +300 to -300 to +300 :-)
  int iSteer = 0;

  // Reply only when you receive data
  if (Serial.available() > 0)
  {
    char character = Serial.read();
    if (character == '\n')
    {
      SendAnswer();
    }
  }
}

SendAnswer() might be the original function from https://github.com/flo199213/Hoverboard-Firmware-Hack-Gen2/blob/master/PPMDeviceArduino_V1.0/PPMDevice/SteeringSerial.cpp

greeting from Germany, Roland and please sign my petition "comprehensive plan for Peace in the world ": www.RoboDurden.de !!!

weiminshen99 commented 1 year ago

I have this hardware Arduino Nano. Is it suitable for the software example you requested?

image
RoboDurden commented 1 year ago

Yes, the Atmega328P can handle 19200 SoftwareSerial. But do not spend too much time on the example. I could copy and paste something in 10 minutest. Simply do not want to do because i completely rewrote the serial communication with my Gen2.x so i do not want do see that old Gen2.0 serial code. With the code and links i posted here, people should succeed with code themselves. But if you really want to support your repo, than a simple .ino with an Atmega238p would be best.

weiminshen99 commented 1 year ago

Thanks for your requests/suggestions. I added a much simpler solution in the repos for testing the motor (on the Slave side):

  1. In the file "Inc/config.h", uncomment the following two lines:

    define SLAVE

    define SLAVE_TEST_MOTOR

  2. type "make flash" to compile and upload the code to the Slave board;
  3. you should see the Slave motor moving back and forth.

Have fun and let me know how it goes.

RoboDurden commented 1 year ago

Yes that is also a good idea. Still users will need some arduino code to make use of the firmware. And most users have never even done any arduino code ! So an arduino example usually is very helpful. Don't want to cause you any trouble. As i said, if i thought it to be very important, i would have already done it. But 99% of all users only do "stupid fun projects", so i am am happy with your repo to compile with my online compiler. And some of the users come up with an arduino example :-)

RoboDurden commented 1 year ago

Sorry i can no longer flash binaries to my gen 2.0 setup even so it was just sitting untouched on my desk for a few months. ST-Link no longer connects. No happiness to spend more time on this today. And tomorrow i will leave again for a few weeks. Someone else will have to test the binaries. P.S. the test binary should be a master so users can check that both motors are spinning before begining with the arduino code. So with my Gen2.x i put the TEST_SPEED in the #ifdef MASTERsection, overwriting the speed and steer that is supposed to be received from the arduino:

        #ifdef TEST_SPEED
            speed = 3 * (ABS((  ((int32_t)steerCounter+100) % 400) - 200) - 100);
        //speed = 300;
        #endif

https://github.com/RoboDurden/Hoverboard-Firmware-Hack-Gen2.x/blob/main/HoverBoardGigaDevice/Src/main.c#L351

weiminshen99 commented 1 year ago

Done.

RoboDurden commented 1 year ago

Nice to see that your are willing to maintain your repo. Thanks :-)