xyz fillament resetter with mcufriends shield help

Hello everyone ,
ive been trying to get this fillament resetter to work with code i found
https://github.com/NeoRame/DaVinci-Cartridge-Programmer/blob/master/README.md

But i think my screen is a different one .
i found a youtube video showing to change

tft.reset();
  tft.begin(0x9341); // SDFP5408
  //tft.invertDisplay(true);
  Serial.begin(115200);
  pinMode(13, OUTPUT);
  read_eeprom(0,128);
  updatevars ();
  splash ();
  drawButtons ();
  drawMenu ();

to

0x9325

this worked and the screen came alive but i think i need to change the library to mcufriends_kbv

but i cannot find how since my coding skill is limited to copy paste :slight_smile:

So now the display works but not the touch , i tried touch shield

09:55:58.703 -> Most Touch Screens use pins 6, 7, A1, A2
09:55:58.737 -> But they can be in ANY order
09:55:58.771 -> e.g. right to left or bottom to top
09:55:58.805 -> or wrong direction
09:55:58.839 -> Edit name and calibration statements
09:55:58.872 -> 
09:55:58.872 -> Please Calibrate.
09:55:58.872 -> ID=0x5408
09:55:58.906 -> Screen is 240x320
09:55:58.906 -> Calibration is: 
09:55:58.940 -> LEFT = 907 RT  = 136
09:55:58.974 -> TOP  = 942 BOT = 139
09:55:58.974 -> Wiring is always PORTRAIT
09:55:59.008 -> YP=15 XM=16
09:55:59.008 -> YM=7 XP=6

i hope someone with more knowledge of coding can help me with my project .

// DaVinci Cartridge Programmer v2.0 by NeoRame (Originally known as DaVinci Filament Configurationv1.0 by CdRsKuLL)

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.h>
#include <Logo.h>            // XYZPrinting Logo

#ifndef _NANODEUNIO_LIB_H
#define _NANODEUNIO_LIB_H

#if ARDUINO >= 100
#include <Arduino.h> // Arduino 1.0
#else
#include <WProgram.h> // Arduino 0022
#endif

#define NANODE_MAC_DEVICE 0xa0
#define NANODE_MAC_ADDRESS 0xfa

class NanodeUNIO {
private:
  byte addr;
public:
  NanodeUNIO(byte address);

  boolean read(byte *buffer,word address,word length);
  boolean start_write(const byte *buffer,word address,word length);
  boolean enable_write(void);
  boolean disable_write(void);
  boolean read_status(byte *status);
  boolean write_status(byte status);
  boolean await_write_complete(void);
  boolean simple_write(const byte *buffer,word address,word length);
};

#endif /* _NANODEUNIO_LIB_H */

// the following are addresses for the various parameters
// to be programmed
#define MATERIAL 0x01   // 1 Byte
#define COLOR 0x02      // 2 Bytes
#define TOTALLEN 0x08   // 4 Bytes
#define NEWLEN 0x0C     // 4 Bytes
#define HEADTEMP 0x10  // 2 Bytes
#define BEDTEMP 0x12  // 2 Bytes
#define MLOC 0x14      // 2 Bytes
#define DLOC 0x16      // 2 Bytes
#define SN 0x18      //12 Bytes
#define CRC 0x24      // 2 Bytes
#define LEN2 0x34      // 4 Bytes

// ==========================================================
int bed = 90;           //default value
int extruder = 210;     //default value
int materialtype = 1;   //Material type 0 - PLA , 1 - ABS , 2 - Flex
int roll = 1;           //Roll length 0 - 120 , 1 - 240 , 2 - 400
int intColor = 1;       //Color 1 = Black as default
char mt[1];
char bt[] = {bed,0x00};
char et[] = {extruder,0x00};
char m[] = {0x41};
char selcolor[15] = "Black"; //Max Letters 15
char cr[] = {0x4B,0x00};

#define UNIO_STARTHEADER 0x55
#define UNIO_READ        0x03
#define UNIO_CRRD        0x06
#define UNIO_WRITE       0x6c
#define UNIO_WREN        0x96
#define UNIO_WRDI        0x91
#define UNIO_RDSR        0x05
#define UNIO_WRSR        0x6e
#define UNIO_ERAL        0x6d
#define UNIO_SETAL       0x67

#define UNIO_TSTBY 600
#define UNIO_TSS    10
#define UNIO_THDR    5
#define UNIO_QUARTER_BIT 10
#define UNIO_FUDGE_FACTOR 5
#define UNIO_OUTPUT() do { DDRD |= 0x10; } while (0)
#define UNIO_INPUT() do { DDRD &= 0xef; } while (0)

static void set_bus(boolean state) {
  PORTD=(PORTD&0xef)|(!!state)<<4;
}

static boolean read_bus(void) {
  return !!(PIND&0x10);
}
static void unio_inter_command_gap(void) {
  set_bus(1);
  delayMicroseconds(UNIO_TSS+UNIO_FUDGE_FACTOR);
}

static void unio_standby_pulse(void) {
  set_bus(0);
  UNIO_OUTPUT();
  delayMicroseconds(UNIO_TSS+UNIO_FUDGE_FACTOR);
  set_bus(1);
  delayMicroseconds(UNIO_TSTBY+UNIO_FUDGE_FACTOR);
}

static volatile boolean rwbit(boolean w) {
  boolean a,b;
  set_bus(!w);
  delayMicroseconds(UNIO_QUARTER_BIT);
  a=read_bus();
  delayMicroseconds(UNIO_QUARTER_BIT);
  set_bus(w);
  delayMicroseconds(UNIO_QUARTER_BIT);
  b=read_bus();
  delayMicroseconds(UNIO_QUARTER_BIT);
  return b&&!a;
}

static boolean read_bit(void) {
  boolean b;
  UNIO_INPUT();
  b=rwbit(1);
  UNIO_OUTPUT();
  return b;
}

static boolean send_byte(byte b, boolean mak) {
  for (int i=0; i<8; i++) {
    rwbit(b&0x80);
    b<<=1;
  }
  rwbit(mak);
  return read_bit();
}

static boolean read_byte(byte *b, boolean mak) {
  byte data=0;
  UNIO_INPUT();
  for (int i=0; i<8; i++) {
    data = (data << 1) | rwbit(1);
  }
  UNIO_OUTPUT();
  *b=data;
  rwbit(mak);
  return read_bit();
}
09:55:58.872 -> ID=0x5408
09:55:58.906 -> Screen is 240x320

You have a SPFD5408 controller. So you would use:

  tft.begin(0x5408); // SPFD5408

However it is safer to check the ID first. e.g.

     uint16_t ID = tft.readID();   // identify which controller is on your display 
     tft.begin(ID);           // and use the correct controller

Note that MCUFRIEND_kbv supports many more controllers than Adafruit_TFTLCD

David.

david_prentice:

09:55:58.872 -> ID=0x5408

09:55:58.906 -> Screen is 240x320



You have a SPFD5408 controller. So you would use:


tft.begin(0x5408); // SPFD5408



However it is safer to check the ID first. e.g.


uint16_t ID = tft.readID();  // identify which controller is on your display
    tft.begin(ID);          // and use the correct controller




Note that MCUFRIEND_kbv supports many more controllers than Adafruit_TFTLCD

David.

0x5408 gives white screen that was in the original code with 0x9325 the screen displays the images but touchscreen doesnt work

The genuine Adafruit_TFTLCD does not support SPFD5408
MCUFRIEND_kbv does support SPFD5408

I suggest that you install libraries properly via the IDE Library Manager.
Then run all the library examples.

Ask questions.

Do not attempt to write / port your own sketches until you have experimented with the examples.

David.

i tried the examples in mcu friends library and some work on the shield most work mirrored .

When i run this gfx calibration i get this .

12:36:55.400 -> TouchScreen.h GFX Calibration
12:36:55.400 -> Making all control and bus pins INPUT_PULLUP
12:36:55.466 -> Typical 30k Analog pullup with corresponding pin
12:36:55.500 -> would read low when digital is written LOW
12:36:55.567 -> e.g. reads ~25 for 300R X direction
12:36:55.602 -> e.g. reads ~30 for 500R Y direction
12:36:55.636 ->
12:36:55.636 -> BROKEN TOUCHSCREEN
12:36:55.842 -> ID = 0x5408

Quote example "name" and problem.
Paste any output from the Serial Terminal

David.

"aspect_kbv"
14:10:52.635 -> ID = 0x5408
Works text mirrored x=50 y=100

"button_simple"
'Adafruit_GFX_Button' does not name a type; did you mean 'Adafruit_GFX'?
Does not compile

"diagnose_tft_support"
14:13:41.350 -> Diagnose whether this controller is supported
14:13:41.385 -> There are FAQs in extras/mcufriend_how_to.txt
14:13:41.419 ->
14:13:41.454 -> tft.readID() finds: ID = 0x5408
14:13:41.488 ->
14:13:41.488 -> MCUFRIEND_kbv version: 2.9.8
14:13:41.488 ->
14:13:41.864 ->
14:13:41.864 -> PORTRAIT is 240 x 320
14:13:41.864 ->
14:13:41.864 -> Run the examples/graphictest_kbv sketch
14:13:41.898 -> All colours, text, directions, rotations, scrolls
14:13:41.932 -> should work. If there is a problem, make notes on paper
14:13:42.000 -> Post accurate description of problem to Forum
14:13:42.069 -> Or post a link to a video (or photos)
14:13:42.104 ->
14:13:42.104 -> I rely on good information from remote users
Works Text mirrored

Go on. You have run the "diagnose_TFT_controller" sketch.

Provide accurate information e.g.
BLUE mirrored (Portrait should have ribbon at bottom of screen)
GREEN ok
RED mirrored
GRAY mirrored

David.

"diagnose_Touchpins"
14:16:43.433 -> Making all control and bus pins INPUT_PULLUP
14:16:43.466 -> Typical 30k Analog pullup with corresponding pin
14:16:43.535 -> would read low when digital is written LOW
14:16:43.535 -> e.g. reads ~25 for 300R X direction
14:16:43.569 -> e.g. reads ~30 for 500R Y direction
14:16:43.603 ->
Nothing on screen but i think i should get more data

"graphicstest_kbv"
14:23:10.701 -> Serial took 0ms to start
14:23:10.936 -> ID = 0x5408

Works but everything mirrored

"LCD_ID_readnew"
14:26:42.249 -> Read Registers on MCUFRIEND UNO shield
14:26:42.283 -> controllers either read as single 16-bit
14:26:42.316 -> e.g. the ID is at readReg(0)
14:26:42.349 -> or as a sequence of 8-bit values
14:26:42.382 -> in special locations (first is dummy)
14:26:42.415 ->
14:26:42.415 -> diagnose any controller
14:26:42.451 -> reg(0x0000) 54 08 ID: ILI9320, ILI9325, ILI9335, ...
14:26:42.518 -> reg(0x0004) 04 04 04 04 Manufacturer ID
14:26:42.553 -> reg(0x0009) 09 09 09 09 09 Status Register
14:26:42.586 -> reg(0x000A) 0A 0A Get Powsr Mode
14:26:42.654 -> reg(0x000C) 0C 0C Get Pixel Format
14:26:42.688 -> reg(0x0030) 30 30 30 30 30 PTLAR
14:26:42.721 -> reg(0x0033) 33 33 33 33 33 33 33 VSCRLDEF
14:26:42.755 -> reg(0x0061) 61 61 RDID1 HX8347-G
14:26:42.789 -> reg(0x0062) 62 62 RDID2 HX8347-G
14:26:42.822 -> reg(0x0063) 63 63 RDID3 HX8347-G
14:26:42.855 -> reg(0x0064) 64 64 RDID1 HX8347-A
14:26:42.890 -> reg(0x0065) 65 65 RDID2 HX8347-A
14:26:42.924 -> reg(0x0066) 66 66 RDID3 HX8347-A
14:26:42.957 -> reg(0x0067) 67 67 RDID Himax HX8347-A
14:26:43.025 -> reg(0x0070) 70 70 Panel Himax HX8347-A
14:26:43.059 -> reg(0x00A1) A1 A1 A1 A1 A1 RD_DDB SSD1963
14:26:43.093 -> reg(0x00B0) B0 B0 RGB Interface Signal Control
14:26:43.160 -> reg(0x00B3) B3 B3 B3 B3 B3 Frame Memory
14:26:43.193 -> reg(0x00B4) B4 B4 Frame Mode
14:26:43.227 -> reg(0x00B6) B6 B6 B6 B6 B6 Display Control
14:26:43.261 -> reg(0x00B7) B7 B7 Entry Mode Set
14:26:43.294 -> reg(0x00BF) BF BF BF BF BF BF ILI9481, HX8357-B
14:26:43.361 -> reg(0x00C0) C0 C0 C0 C0 C0 C0 C0 C0 C0 Panel Control
14:26:43.429 -> reg(0x00C1) C1 C1 C1 C1 Display Timing
14:26:43.463 -> reg(0x00C5) C5 C5 Frame Rate
14:26:43.497 -> reg(0x00C8) C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 GAMMA
14:26:43.564 -> reg(0x00CC) CC CC Panel Control
14:26:43.597 -> reg(0x00D0) D0 D0 D0 D0 Power Control
14:26:43.631 -> reg(0x00D1) D1 D1 D1 D1 VCOM Control
14:26:43.666 -> reg(0x00D2) D2 D2 D2 Power Normal
14:26:43.700 -> reg(0x00D3) D3 D3 D3 D3 ILI9341, ILI9488
14:26:43.733 -> reg(0x00D4) D4 D4 D4 D4 Novatek
14:26:43.800 -> reg(0x00DA) 00 00 RDID1
14:26:43.800 -> reg(0x00DB) 00 00 RDID2
14:26:43.835 -> reg(0x00DC) DC DC RDID3
14:26:43.835 -> reg(0x00E0) E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 GAMMA-P
14:26:43.903 -> reg(0x00E1) E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 GAMMA-N
14:26:43.971 -> reg(0x00EF) EF EF EF EF EF EF ILI9327
14:26:44.005 -> reg(0x00F2) F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 Adjust Control 2
14:26:44.074 -> reg(0x00F6) F6 F6 F6 F6 Interface Control

david_prentice:
Go on. You have run the "diagnose_TFT_controller" sketch.

Provide accurate information e.g.
BLUE mirrored (Portrait should have ribbon at bottom of screen)
GREEN ok
RED mirrored
GRAY mirrored

David.

Every text is mirrored all in a rectangle

"lcd_ID_readreg"
14:38:49.938 -> Read Registers on MCUFRIEND UNO shield
14:38:49.972 -> controllers either read as single 16-bit
14:38:50.007 -> e.g. the ID is at readReg(0)
14:38:50.041 -> or as a sequence of 8-bit values
14:38:50.075 -> in special locations (first is dummy)
14:38:50.109 ->
14:38:50.109 -> reg(0x0000) 54 08 ID: ILI9320, ILI9325, ILI9335, ...
14:38:50.178 -> reg(0x0004) 04 04 04 04 Manufacturer ID
14:38:50.213 -> reg(0x0009) 09 09 09 09 09 Status Register
14:38:50.281 -> reg(0x000A) 0A 0A Get Power Mode
14:38:50.315 -> reg(0x000C) 0C 0C Get Pixel Format
14:38:50.348 -> reg(0x0061) 61 61 RDID1 HX8347-G
14:38:50.381 -> reg(0x0062) 62 62 RDID2 HX8347-G
14:38:50.416 -> reg(0x0063) 63 63 RDID3 HX8347-G
14:38:50.450 -> reg(0x0064) 64 64 RDID1 HX8347-A
14:38:50.484 -> reg(0x0065) 65 65 RDID2 HX8347-A
14:38:50.519 -> reg(0x0066) 66 66 RDID3 HX8347-A
14:38:50.552 -> reg(0x0067) 67 67 RDID Himax HX8347-A
14:38:50.586 -> reg(0x0070) 70 70 Panel Himax HX8347-A
14:38:50.621 -> reg(0x00A1) A1 A1 A1 A1 A1 RD_DDB SSD1963
14:38:50.656 -> reg(0x00B0) B0 B0 RGB Interface Signal Control
14:38:50.725 -> reg(0x00B4) B4 B4 Inversion Control
14:38:50.759 -> reg(0x00B6) B6 B6 B6 B6 B6 Display Control
14:38:50.792 -> reg(0x00B7) B7 B7 Entry Mode Set
14:38:50.827 -> reg(0x00BF) BF BF BF BF BF BF ILI9481, HX8357-B
14:38:50.895 -> reg(0x00C0) C0 C0 C0 C0 C0 C0 C0 C0 C0 Panel Control
14:38:50.930 -> reg(0x00C8) C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 GAMMA
14:38:50.999 -> reg(0x00CC) CC CC Panel Control
14:38:51.033 -> reg(0x00D0) D0 D0 D0 Power Control
14:38:51.066 -> reg(0x00D2) D2 D2 D2 D2 D2 NVM Read
14:38:51.135 -> reg(0x00D3) D3 D3 D3 D3 ILI9341, ILI9488
14:38:51.170 -> reg(0x00D4) D4 D4 D4 D4 Novatek ID
14:38:51.205 -> reg(0x00DA) 00 00 RDID1
14:38:51.238 -> reg(0x00DB) 00 00 RDID2
14:38:51.274 -> reg(0x00DC) DC DC RDID3
14:38:51.274 -> reg(0x00E0) E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 GAMMA-P
14:38:51.343 -> reg(0x00E1) E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 GAMMA-N
14:38:51.443 -> reg(0x00EF) EF EF EF EF EF EF ILI9327
14:38:51.477 -> reg(0x00F2) F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 Adjust Control 2
14:38:51.545 -> reg(0x00F6) F6 F6 F6 F6 Interface Control
Nothing on screen

"readpixel_kbv"
14:42:07.397 -> readID = 0x5408
alot of 00000fffff all mirrored portrait and landscape

"scroll_kbv"

Counts all mirrored White text

"testcard_kbv"

14:49:38.286 -> TFT ID = 0x5408

working mirrored

"Touch_shield_new"

14:52:52.795 -> Most Touch Screens use pins 6, 7, A1, A2
14:52:52.830 -> But they can be in ANY order
14:52:52.864 -> e.g. right to left or bottom to top
14:52:52.899 -> or wrong direction
14:52:52.933 -> Edit name and calibration statements
14:52:52.966 ->
14:52:52.966 -> Please Calibrate.
14:52:52.966 -> ID=0x5408
14:52:53.001 -> Screen is 240x320
14:52:53.001 -> Calibration is:
14:52:53.001 -> LEFT = 907 RT = 136
14:52:53.034 -> TOP = 942 BOT = 139
14:52:53.034 -> Wiring is always PORTRAIT
14:52:53.068 -> YP=15 XM=16
14:52:53.068 -> YM=7 XP=6

Everything on screen is mirrored
x and y value keep jumping but only react when pressing bottom half of the screen

Horizontal mirror is different to Vertical mirror.

e.g. BLUE PORTRAIT should have ribbon at bottom of the screen. USB cable at top of the screen.

Your readreg report is fine.

From MCUFRIEND_kbv.cpp

    case 0x5408:
        _lcd_capable = 0 | REV_SCREEN | READ_BGR; //Red 2.4" thanks jorgenv, Ardlab_Gent
//        _lcd_capable = 0 | REV_SCREEN | READ_BGR | INVERT_GS; //Blue 2.8" might be different
        goto common_9320;

If you have a Blue Shield, you might need to comment the Red line, uncomment the Blue line.

Sorry to be pedantic. It is useful to know what colour pcb your Shield has.

“Touchscreen_Caklibr_native”
14:59:26.550 → TouchScreen.h GFX Calibration
14:59:26.550 → Making all control and bus pins INPUT_PULLUP
14:59:26.618 → Typical 30k Analog pullup with corresponding pin
14:59:26.653 → would read low when digital is written LOW
14:59:26.721 → e.g. reads ~25 for 300R X direction
14:59:26.756 → e.g. reads ~30 for 500R Y direction
14:59:26.791 →
14:59:26.791 → BROKEN TOUCHSCREEN
14:59:26.997 → ID = 0x5408

When i run
“touchcreendemoshield”
and set min pressure to 100 it registeres only when touching the bottom half
15:02:46.975 → X = 547 Y = 897 Pressure = 455
15:02:47.009 → X = 551 Y = 894 Pressure = 447
15:02:47.043 → X = 549 Y = 896 Pressure = 459
15:02:47.076 → X = 550 Y = 895 Pressure = 456
15:02:47.110 → X = 550 Y = 895 Pressure = 455
15:02:47.145 → X = 551 Y = 896 Pressure = 461
15:02:47.179 → X = 550 Y = 895 Pressure = 455
15:02:47.213 → X = 550 Y = 896 Pressure = 463
15:02:47.247 → X = 552 Y = 895 Pressure = 448
15:02:47.280 → X = 550 Y = 671 Pressure = 108

Its this one only mine has text on it mcufriend.com
tftlcd for arduino uno (spiflah)

Please just answer the question. What does the PORTRAIT screen (BLUE) look like?
Is text Horizontally or Vertically mirrored?

If you don’t know, post a photo.

Your shield is definitely Red 2.4 inch pcb.
Have you tried editing MCUFRIEND_kbv.cpp ?
It is worth trying the 2.8 inch setting.

Your TouchScreen is BROKEN. There is no possibility of mending it.

David.

well if the touchscreen is broken i need another shield .

Can u advise a model that will work with the used libraries .

include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.h>

Your photo is upside down. The USB cable and pushbutton K1 should be at the top.
The House icon, mail icon, … should be at the bottom.

Your screen is Vertically mirrored. Edit MCUFRIEND_kbv.cpp so that it looks like this:

    case 0x5408:
//        _lcd_capable = 0 | REV_SCREEN | READ_BGR; //Red 2.4" thanks jorgenv, Ardlab_Gent
        _lcd_capable = 0 | REV_SCREEN | READ_BGR | INVERT_GS; //Blue 2.8" might be different
        goto common_9320;

i.e. the 2.8 inch setting.

Your photo does not show a cracked glass screen. Perhaps the 4-way (Touch) ribbon is broken.

David.

yeah screen came in 2 days ago .

I ordered another one so hope this one will work as it should .

How do i alter the code to use the mcufriend library instead of the adafruit library