Its simple really, whenever I create a rectangle using Bdisp_Rectangle(0, 0, 10, 10, TEXT_COLOR_RED) it creates a rectangle like it says it does, however it is an empty/hollow rectangle. Does anyone know of a way to apply a fill to it and make it a solid rectangle? Thanks
OMG, thanks so much, how did u come across this function I didn't see it inside the document. Is there another document that is more comprehensive. Thanks
MateoConLechuga wrote:
I believe you can use the function Bdisp_FilledRectangle instead.
Hey, thanks for the reply but do you know how to change the position of the rectangle, because I am planning to make a game but I need the rectangle to move when a button is clicked and when I put the rectangle function in the while loop it just doesn't render, thanks
Well the header has all of them, presumably: https://github.com/Jonimoose/libfxcg/blob/master/include/fxcg/display.h
Adriweb wrote:
Well the header has all of them, presumably: https://github.com/Jonimoose/libfxcg/blob/master/include/fxcg/display.h
Thanks a lot this seems very helpful
MichaelY wrote:
MateoConLechuga wrote:
I believe you can use the function Bdisp_FilledRectangle instead.
Hey, thanks for the reply but do you know how to change the position of the rectangle, because I am planning to make a game but I need the rectangle to move when a button is clicked and when I put the rectangle function in the while loop it just doesn't render, thanks
I'm not entirely sure what you mean, but Bdisp_Rectangle and Bdisp_FiledRectangle both draw to the VRAM, which means that you have to call Bdisp_PutDisp_DD(), or GetKey() which calls Bdisp_PutDisp_DD() to draw the VRAM to the screen.
Hey, dr-carlos after a lot of digging and investigation I have worked it out.
For anyone who wants to draw a rectangle to the screen and move it around do this:
First you need to call
Code:
- to get information on the parameters have a look here https://prizm.cemetech.net/index.php?title=Category:Syscalls
Next you need to detect keypresses, I used
Code:
to get the input from keyboard and have a variable that changes based on whether the right key is pressed or left
Next inside the infinite loop you need to clear the VRAM (basically the screen) using
Code:
and then use the function
Code:
to draw the rectangle again, finally you need to push the VRAM to the screen through
Code:
and that's it.
Thanks a lot to everyone who helped me
For anyone who wants to draw a rectangle to the screen and move it around do this:
First you need to call
Code:
Bdisp_FilledRectangle(x, y, x2, y2, TEXT_COLOR_BLACK);
Next you need to detect keypresses, I used
Code:
GetKeyWait_OS
Next inside the infinite loop you need to clear the VRAM (basically the screen) using
Code:
Bdisp_AllClr_VRAM()
Code:
Bdisp_FilledRectangle()
Code:
Bdisp_PutDisp_DD()
Thanks a lot to everyone who helped me
dr-carlos wrote:
MichaelY wrote:
MateoConLechuga wrote:
I believe you can use the function Bdisp_FilledRectangle instead.
Hey, thanks for the reply but do you know how to change the position of the rectangle, because I am planning to make a game but I need the rectangle to move when a button is clicked and when I put the rectangle function in the while loop it just doesn't render, thanks
I'm not entirely sure what you mean, but Bdisp_Rectangle and Bdisp_FiledRectangle both draw to the VRAM, which means that you have to call Bdisp_PutDisp_DD(), or GetKey() which calls Bdisp_PutDisp_DD() to draw the VRAM to the screen.
Hey, thanks a lot for your contribution but I have another question, whenever I have an error it just says "Aborted, press [menu] to exit" yet there is nothing about the error, do you know where I can find the logs or error report?
MichaelY wrote:
Hey, thanks a lot for your contribution but I have another question, whenever I have an error it just says "Aborted, press [menu] to exit" yet there is nothing about the error, do you know where I can find the logs or error report?
Not really, the calculator isn't good with errors.
What were you running before the error occured?
MichaelY wrote:
Hey, dr-carlos after a lot of digging and investigation I have worked it out.
For anyone who wants to draw a rectangle to the screen and move it around do this:
First you need to call
Code:
- to get information on the parameters have a look here https://prizm.cemetech.net/index.php?title=Category:Syscalls
Next you need to detect keypresses, I used
Code:
to get the input from keyboard and have a variable that changes based on whether the right key is pressed or left
Next inside the infinite loop you need to clear the VRAM (basically the screen) using
Code:
and then use the function
Code:
to draw the rectangle again, finally you need to push the VRAM to the screen through
Code:
and that's it.
Thanks a lot to everyone who helped me
For anyone who wants to draw a rectangle to the screen and move it around do this:
First you need to call
Code:
Bdisp_FilledRectangle(x, y, x2, y2, TEXT_COLOR_BLACK);
Next you need to detect keypresses, I used
Code:
GetKeyWait_OS
Next inside the infinite loop you need to clear the VRAM (basically the screen) using
Code:
Bdisp_AllClr_VRAM()
Code:
Bdisp_FilledRectangle()
Code:
Bdisp_PutDisp_DD()
Thanks a lot to everyone who helped me
Yep, that should all work. Note that Bdisp_AllClr_VRAM() isn't very fast, so if you want better performance, consider drawing a white Bdisp_FilledRectangle where the previous one was, or read this wiki article (the Optimization section) on how to do this even faster.
Thanks dr-carlos here is the line that is causing the error:
unsigned int *hour, *minute, *second, *millisecond;
RTC_GetTime(&hour, &minute, &second, &millisecond);
When I remove the bottom line the code runs fine, is there a problem with how I am using the function.
Just so you know this is a short snippet of my entire code
unsigned int *hour, *minute, *second, *millisecond;
RTC_GetTime(&hour, &minute, &second, &millisecond);
When I remove the bottom line the code runs fine, is there a problem with how I am using the function.
Just so you know this is a short snippet of my entire code
MateoConLechuga wrote:
Get rid of the *
Yes, Mateo is right. You have created pointers and then passed in references to those pointers.
Now you are passing in int** types, instead of int* types which the function is expecting. This will also not work because your pointers are uninitialised. This means that hour, minute, second, and millisecond are effectively null pointers and this may crash RTC_GetTime.
Instead, use:
Code:
unsigned int hour, minute, second, millisecond;
RTC_GetTime(&hour, &minute, &second, &millisecond);
I am trying to learn C, and so here is what I understand. I am currently giving the address of a pointer which points to nothing (NULL) as I haven't told them what address to point to.
So if I understand correctly:
Code:
So what I am passing into the function is an pointer, well a parameter storing an address and that parameter points to a pointer which address stored points to NULL
Are all of my intuition correct?
So if I understand correctly:
Code:
int var = 0, *i = &var;
&I // This is the address of the pointer
So what I am passing into the function is an pointer, well a parameter storing an address and that parameter points to a pointer which address stored points to NULL
Are all of my intuition correct?
So is the code I described below correct, as I presume what is being passed into func is actually the address of a pointer which points to 0
int func(int** i){
printf("%d", *(*i)); // Is this correct??
}
int main() {
int var = 0, *i = &var;
func(&i);
return 0;
}
Thanks a lot
int func(int** i){
printf("%d", *(*i)); // Is this correct??
}
int main() {
int var = 0, *i = &var;
func(&i);
return 0;
}
Thanks a lot
MichaelY wrote:
So is the code I described below correct, as I presume what is being passed into func is actually the address of a pointer which points to 0
int func(int** i){
printf("%d", *(*i)); // Is this correct??
}
int main() {
int var = 0, *i = &var;
func(&i);
return 0;
}
Thanks a lot
int func(int** i){
printf("%d", *(*i)); // Is this correct??
}
int main() {
int var = 0, *i = &var;
func(&i);
return 0;
}
Thanks a lot
Yes, this would print 0.
However, in the case of RTC_GetTime, it expects unsigned int* arguments. See the code I posted previously for how this should be done.
I used your code and it works fine dr-carlos, but could you tell me how accurate is the millisecond value returned, I think I saw it somewhere and it was around 1/128th of a second for every update of that value. The reason why is because I want to know how to run a piece of code x times every second. Thanks
MichaelY wrote:
I used your code and it works fine dr-carlos, but could you tell me how accurate is the millisecond value returned, I think I saw it somewhere and it was around 1/128th of a second for every update of that value. The reason why is because I want to know how to run a piece of code x times every second. Thanks
The base tick of the Real-Time Clock is 1/128th of a second.
Therefore, the millisecond provided is accurate to 1/128th of a second.
There are approximately 7 milliseconds per 1/128th of a second.
Another way of doing this would be to use RTC_GetTicks(), which returns the number of ticks (1/128ths of second) since midnight.
dr-carlos wrote:
MichaelY wrote:
I used your code and it works fine dr-carlos, but could you tell me how accurate is the millisecond value returned, I think I saw it somewhere and it was around 1/128th of a second for every update of that value. The reason why is because I want to know how to run a piece of code x times every second. Thanks
The base tick of the Real-Time Clock is 1/128th of a second.
Therefore, the millisecond provided is accurate to 1/128th of a second.
There are approximately 7 milliseconds per 1/128th of a second.
Another way of doing this would be to use RTC_GetTicks(), which returns the number of ticks (1/128ths of second) since midnight.
Thanks now this is completely unrelated but when specifying the color in PromtXY, is there a way to use an rgb color? Thanks
MichaelY wrote:
dr-carlos wrote:
MichaelY wrote:
I used your code and it works fine dr-carlos, but could you tell me how accurate is the millisecond value returned, I think I saw it somewhere and it was around 1/128th of a second for every update of that value. The reason why is because I want to know how to run a piece of code x times every second. Thanks
The base tick of the Real-Time Clock is 1/128th of a second.
Therefore, the millisecond provided is accurate to 1/128th of a second.
There are approximately 7 milliseconds per 1/128th of a second.
Another way of doing this would be to use RTC_GetTicks(), which returns the number of ticks (1/128ths of second) since midnight.
Thanks now this is completely unrelated but when specifying the color in PromtXY, is there a way to use an rgb color? Thanks
Not in PrintXY, but there is another function, PrintCXY, which does what you are looking for.
See its wiki article for details.
Note that PrintCXY uses pixels instead of columns and rows. These can be converted as follows:
x = (Row - 1) * 18
y = (Column - 1) * 24
Also note that the PrintCXY message string does not require two spaces at the start.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
» Go to Registration page
» Go to Registration page
» Goto page 1, 2 Next
» View previous topic :: View next topic
» View previous topic :: View next topic
Page 1 of 2
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Advertisement