Problem bei der Programierung des TX Controllers in C

Alles rund um TX(T) und RoboPro, mit ft-Hard- und Software
Computing using original ft hard- and software
Forumsregeln
Bitte beachte die Forumsregeln!
Antworten
Martin S
Beiträge: 5
Registriert: 27 Mär 2012, 14:25

Problem bei der Programierung des TX Controllers in C

Beitrag von Martin S » 27 Mär 2012, 15:09

Hallo

Ich hab folgende Frage
Wie kann ich einzelne Pixel des Displays anmachen?
Ich weiß von den Beispielen das man eine Art Message Box mit

Code: Alles auswählen

p_ta->hook_table.DisplayMsg(p_ta, "Nachricht");
aufrufen kann. Ich würde mich aber mal an einem Tetris versuchen wollen wo ich einzelne Pixel setzten muss versuchen.

Mfg Martin S

vleeuwen
Beiträge: 1609
Registriert: 31 Okt 2010, 22:23
Wohnort: Enschede (NL)
Kontaktdaten:

Re: Problem bei der Programierung des TX Controllers in C

Beitrag von vleeuwen » 27 Mär 2012, 16:22

See (teil 2 version 1.4)
8.8 Struktur TA_DISPLAY

I guess that you must use the DISPLAY_FRAME struct to display bitmap images.
But this part is not realy documented.
You need to figure out how it works yourself.

Martin S
Beiträge: 5
Registriert: 27 Mär 2012, 14:25

Re: Problem bei der Programierung des TX Controllers in C

Beitrag von Martin S » 27 Mär 2012, 17:07

Have you an idea how this could work?
I tested many but nothing did work.
I would be very lucky if you have a solution.

Mfg Martin S

vleeuwen
Beiträge: 1609
Registriert: 31 Okt 2010, 22:23
Wohnort: Enschede (NL)
Kontaktdaten:

Re: Problem bei der Programierung des TX Controllers in C

Beitrag von vleeuwen » 27 Mär 2012, 18:33

I did not had time to test it but my hypothesis is:


DISPLAY_MSG.id=0; (do not make use of DISPLAY_MSG struct)

DISPLAY_FRAME.FRAME points to a 128*8 bytes array representing the bitmap (b/w).
DISPLAY_FRAME.is_pgm_master_of display= true
DISPLAY_FRAME.id=1 //probabely the change of this value will activate the transfer of the bitmap.
//
The bitmap will be transfer to the TX-C in parts (pages of 64 bytes).
The Transfer Area do not have more space available for the display information.
So there are 16 TA cycles needed to tranfsfer 1 bitmap.

I am expecting that the DISPLAY_MSG will be use by the transfer software to transfer the pages.

Let me know if this is working.

Martin S
Beiträge: 5
Registriert: 27 Mär 2012, 14:25

Re: Problem bei der Programierung des TX Controllers in C

Beitrag von Martin S » 29 Mär 2012, 22:27

Hello
I´ve got this code now witch display me something like a big chaos.

Code: Alles auswählen

        unsigned char temp[64];
	p_ta->display.display_msg.id=0;
	p_ta->display.display_frame.is_pgm_master_of_display = 1;
	p_ta->display.display_frame.id=1;
	int z;
	for (z= 1;z <= 16;z++){
	p_ta->display.display_frame.frame=temp; 
	}
I expected to get a blank screen.

Mfg Martin
Zuletzt geändert von Martin S am 29 Mär 2012, 22:30, insgesamt 1-mal geändert.

Martin S
Beiträge: 5
Registriert: 27 Mär 2012, 14:25

Re: Problem bei der Programierung des TX Controllers in C

Beitrag von Martin S » 29 Mär 2012, 22:27

Mein Browser hat die letzt Nachricht doppelt gesendet.
Könnte das hier bitte jemand lösche.

vleeuwen
Beiträge: 1609
Registriert: 31 Okt 2010, 22:23
Wohnort: Enschede (NL)
Kontaktdaten:

Re: Problem bei der Programierung des TX Controllers in C

Beitrag von vleeuwen » 29 Mär 2012, 23:17

Based on the documentation I am expecting that the
p_ta->display.display_frame.frame needs to contain a pointer to a 128*8 bytes array.
This array needs to contain representing the bitmap (b/w).

The split up of this array into parts will be done by the FtMscLib self.

Try to monitor the value of the id and the pointer.
Sorry that I don't have time to test this myself.


unsigned char * bitmapPointer;
unsigned char bitmap[128*8];
tempPointer=bitmap;

Don't forget to created the array itself.
Zuletzt geändert von vleeuwen am 30 Mär 2012, 17:53, insgesamt 1-mal geändert.

Ad2
Beiträge: 306
Registriert: 31 Okt 2010, 22:20

Re: Problem bei der Programierung des TX Controllers in C

Beitrag von Ad2 » 30 Mär 2012, 17:01

@Martin S

Your code:

Code: Alles auswählen

        unsigned char temp[64];
   p_ta->display.display_msg.id=0;
   p_ta->display.display_frame.is_pgm_master_of_display = 1;
   p_ta->display.display_frame.id=1;
   int z;
   for (z= 1;z <= 16;z++){
   p_ta->display.display_frame.frame=temp; 
   }
Has some C errors. There is no assignment of entire arrays in C. var=temp; assigns the address of the array 'temp' to var, not the values in temp. Array indices in C start at 0, although you don't use 'z' as an index (why not?) it should normally look like "for (z=0;z<64;z++)". Furthermore your array temp likely contains random data.
On the positive side: At least something is happening.

Ad

Martin S
Beiträge: 5
Registriert: 27 Mär 2012, 14:25

Re: Problem bei der Programierung des TX Controllers in C

Beitrag von Martin S » 01 Apr 2012, 18:54

I feel realy helpless now. :(

Here is my current code :

Code: Alles auswählen

int i;
int PrgTic
(
    TA * p_ta_array,    // pointer to the array of transfer areas
    int ta_count        // number of transfer areas in array (equal to TA_COUNT)
)
{
    int rc = 0x7FFF;
    TA * p_ta = &p_ta_array[TA_IDX]; 
	unsigned char * bitmap[64];
	int z;
	if(i==0){
	
		p_ta->display.display_msg.id=0;
		p_ta->display.display_frame.is_pgm_master_of_display = 1;
	
	}
	if(i<16){
		
		
		p_ta->display.display_frame.id=+1;
		p_ta->display.display_frame.frame=bitmap; 
		

	}
	i++;
	return rc;
}
I don´t know whats gone wrong.
I get a Chaos on the display and some pixels are blinking.
I would be very happy if i get some help. :D

Mfg Martin525

vleeuwen
Beiträge: 1609
Registriert: 31 Okt 2010, 22:23
Wohnort: Enschede (NL)
Kontaktdaten:

Re: Problem bei der Programierung des TX Controllers in C

Beitrag von vleeuwen » 01 Apr 2012, 19:34

A couple of thinks in your code are not clear to me

1)
A bitmap is 128*64 bits (or 128*8 bytes).
-> Where is this bitmap defined in your code?
->What is the value of each pixel (bit, black or white)?

2)
What is the role of i?

Did you create a 128*8 byte array (allogate memory space for this array; with each byte =0)?

The TA description only ask for a pointer to an existing bitmap array (of 128*64 bits (128*8 bytes) and not 64*8 bytes).
And to increase the Id.
After that wait and see what will happen.

Ad2
Beiträge: 306
Registriert: 31 Okt 2010, 22:20

Re: Problem bei der Programierung des TX Controllers in C

Beitrag von Ad2 » 02 Apr 2012, 10:43

Hi,

I haven't tried myself but I have some comments on your code

Code: Alles auswählen

int i; //make this int i = 0;  variables should be initialised
int PrgTic
(
    TA * p_ta_array,    // pointer to the array of transfer areas
    int ta_count        // number of transfer areas in array (equal to TA_COUNT)
)
{
    int rc = 0x7FFF;
    TA * p_ta = &p_ta_array[TA_IDX]; //I guess TA_IDX is the index for your current TX controller
   unsigned char * bitmap[64]; //this defines an automatic array of 64 pointers to bytes and is NOT initialised, this is probably not you intend
   int z; //unused
   if(i==0){ //first time
   
      p_ta->display.display_msg.id=0;
      p_ta->display.display_frame.is_pgm_master_of_display = 1;
   
   }
   if(i<16){ //16 times
      
      
      p_ta->display.display_frame.id=+1;// not clear: =+ used to be an operator (deprecated), write: var = 1; or var += 1; depending on what you mean
      p_ta->display.display_frame.frame=bitmap; //this assigns the address of your array of pointers to the frame variable, the array is on the stack so both its address and 
                                                                       //contents may vary from invocation to invocation. recommendation: use a static array, eg.: static unsigned char bitmap[128];
                                                                       //and initialise it in eg. i==0. Or even easier, declare it globally, initialise it in the init function and update it in the tick function.
      

   }
   i++;
   return rc;
}

Antworten