Wanhao I3 Plus Firmware Description

Wanhao Changes to Marlin for Touch LCD

These are the changes made to the Marlin branch to add support for the touch screen Wanhao uses on the Plus. The main board basically sends a packet out the serial port (called BTSERIAL or MySerial2 in the code) with the various status variables that are to be shown on the LCD. There are a few functions that send out various data and also the main incoming touch data from the LCD. Here is what I have found so far:

The function that is called to send the status packet out is lcd_vs_temp_data(). Here is the code that stuffs and sends the packet:

 vs_lcd_data[0]=0x5A;
 vs_lcd_data[1]=0xA5;
 vs_lcd_data[2]=0x21;
 vs_lcd_data[3]=0x82;
 vs_lcd_data[4]=0x00;
 vs_lcd_data[5]=0x01;
 
 tmp_extru=degHotend(tmp1_extruder);
 if(tmp_extru>255)
 {
 vs_lcd_data[6]=0x01;
 tmp_extru=tmp_extru-256;
 }
 else
 { 
 vs_lcd_data[6]=0x00;
 }
 vs_lcd_data[7]=(char)((int)tmp_extru);
 vs_lcd_data[8]=0x00;
 vs_lcd_data[9]=0x00;
 vs_lcd_data[10]=0x00;
 vs_lcd_data[11]=(char)((int)degBed());
 vs_lcd_data[12]=0x00;
 vs_lcd_data[13]=fanSpeed*100/255;
 vs_lcd_data[14]=0x00;
 vs_lcd_data[15]=card.percentDone(); 
 vs_lcd_data[16]=0x00;
 vs_lcd_data[17]=0x00;
 vs_lcd_data[18]=0x00;
 vs_lcd_data[19]=0x00;
 vs_lcd_data[20]=0x00;
 vs_lcd_data[21]=0x00;
 vs_lcd_data[22]=0x00;
 vs_lcd_data[23]=0x00;
 vs_lcd_data[24]=0x00;
 vs_lcd_data[25]=0x00;

 int tmp_extru;
 tmp_extru=target_temperature[0];
 if(tmp_extru>255)
 {
 vs_lcd_data[26]=0x01;
 tmp_extru=tmp_extru-256;
 }
 else
 { 
 vs_lcd_data[26]=0x00;
 }
 vs_lcd_data[27]=(char)tmp_extru;

 vs_lcd_data[28]=0x00;
 vs_lcd_data[29]=0x00;

 vs_lcd_data[30]=0x00;
 vs_lcd_data[31]=(char)target_temperature_bed;

 int temp_print_percent=feedmultiply;
 if(temp_print_percent>255)
 {
 vs_lcd_data[32]=0x01;
 temp_print_percent=temp_print_percent-256;
 }
 else
 {
 vs_lcd_data[32]=0x00;
 }

 vs_lcd_data[33]=(char)temp_print_percent;

 vs_lcd_data[34]=0x00;
 vs_lcd_data[35]=0x00;

So the 36 byte packet is sent out periodically. After each packet is sent it checks to see if a print is in progress and how far along it is then calls another routing:

 if(IS_SD_PRINTING && card.percentDone()>98)
 {
 if(acceleration>1000)
 lcd_vs_App_Page(0x45);
 else
 lcd_vs_App_Page(0x9D);
 }

The lcd_vs_App_Page(temp_page) sends the following:

 vs_lcd_data[0]=0x5A;
 vs_lcd_data[1]=0xA5;
 vs_lcd_data[2]=0x04;
 vs_lcd_data[3]=0x80;
 vs_lcd_data[4]=0x03;

 vs_lcd_data[5]=0x00;
 vs_lcd_data[6]=temp_page;

The lcd_vs_status(lan) function sends out the following:

 vs_lcd_data[0]=0x5A;
 vs_lcd_data[1]=0xA5;
 vs_lcd_data[2]=0x05;
 vs_lcd_data[3]=0x82;
 vs_lcd_data[4]=0x00;
 vs_lcd_data[5]=0x05;
 vs_lcd_data[6]=0x00;
 vs_lcd_data[7]=lan;

The lcd_vs_com_loop(comdate0, comdate1) sends out the following:

 vs_lcd_data[0]=0x5A;
 vs_lcd_data[1]=0xA5;
 vs_lcd_data[2]=0x04;
 vs_lcd_data[3]=0x83;
 vs_lcd_data[4]=comdate0;
 vs_lcd_data[5]=comdate1;
 vs_lcd_data[6]=0x01;

The incoming data processor from the LCD is called lcd_vs_command(). This function reads the data from the serial port and does some sanity checking on the packet before processing it:

 if(90!=lcd_vs_com_data[0] && 165!=lcd_vs_com_data[1] && 3<lcd_vs_com_data[4])

It then checks byte 6 for the command:

  • 1 is used to move the axis based on byte 9
    • 0x00: Moves X +10
    • 0x01: Moves X -10
    • 0x02: Moves Y +10
    • 0x03: Moves Y -10
    • 0x04: Moves Z +5
    • 0x05: Moves Z -5
    • 0x06: Moves Extruder -10 (retracts)
    • 0x07: Moves Extruder +10 (extrudes)
  • 28 homes all “G28” then disables steppers “M84”
  • 50
  • 51
  • 52 sets the bed and extruder temperature to 0 (turns off)
  • 53 seems to be a Stop / Abort print command
  • 54 pauses the print by sending “G1 X5 Y5”.
  • 55 starts a paused print
  • 56 adjusts the feed multiplier based on byte 9 (if >0 it increases the multiplier by 5 otherwise it decreases by 5)
  • 57 adjusts the extruder temperature based on byte 9 (if >0 it increases the temp otherwise it decreases the temp)
  • 58 adjusts the bed temperature based on byte 9 (if >0 it increases the temp otherwise it decreases the temp)
  • 59 adjusts the fan speed based on byte 9 (if >0 it increases the speed by 3 otherwise it decreases the speed by 3)
  • 60 sets bed and extruder preheat to PLA (hard coded to 185 for extruder and 50 for bed)
  • 61 sets bed and extruder preheat to ABS (hard coded to 210 for extruder and 70 for bed)
  • 62 shows the PID settings
  • 63 sets the PID
  • 64 seems to get the current fan, temps and multiplier from the LCD and sends a gcode “M104 T0 Sxxx”
  • 65 stores the new changes to EEPROM
  • 66 resets settings to default and saves to EEPROM
  • 67 homes X “G28 X0”
  • 68 homes Y “G28 Y0”
  • 69 homes Z “G28 Z0”
  • 70 sets the hotend to 190 then homes all “G28”  then moves to X120 Y0 Z 50: “G1 X120 Y0 Z50”
  • 71 seems to send the current feed multiplier, hotend temp, bed temp and fan speed to the LCD.
  • 72 seems to set the hotend to 200 and extrude 0.68mm per tap
  • 73 seems to set the hotend to 200 and retract 4mm per tap
  • 74 disables the stepper motors using “M84”
  • 75 ?
  • 76 looks like it does the bed leveling assistant by sending move commands based on the contents of byte 9
    • 0x00: “G28 F10000”
    • 0x01: “G1 F10000 X30 Y30 Z20”, “G28 Z0”
    • 0x02: “G1 X185 Y30 Z20”,  “G28 Z0”
    • 0x03: “G1 X185 Y185 Z20”, “G28 Z0”
    • 0x04: “G1 X30 Y185 Z20”, “G28 Z0”
    • 0x05: “G28”, “G1 Z30”, “M84” (moves to Z30 and disables steppers)
  • 81 sends gcode “M81”
  • 84 sends gcode “M84” (disables steppers)
Skip to toolbar