Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base the 'msleep' function on MillisElapsed #1862

Open
wants to merge 10,000 commits into
base: master
Choose a base branch
from
Open

Conversation

Acssiohm
Copy link

@Acssiohm Acssiohm commented Aug 4, 2021

I just tried to apply the "TODO", but I'm not sure if it's what was expected.

HugoNumworks and others added 30 commits November 4, 2020 15:58
Change-Id: Icd65c4e19b78cd8751d6b1b583c112abb08c9237
Change-Id: If8904ca4e7d306376de785a125fe5fba168de718
Change-Id: I841bd22077cccacc7d2a4a541cca2e463f13925b
Change-Id: I834444aee7dd547c71254df4658c0db05eb101d7
Change-Id: If88f91d6e925dbb2ad293b537661eb3d137ea826
A previous fix to prevent AlphaLock from interfering with the long press
feature broke the long press selection. Revert the changes and find
another solution to the previous problem.
We compare the alpha status to both the state of the Alpha key and the
Lock, which makes sense : Lock is supposed to mimic Alpha being
continuously pressed.

Change-Id: I1349eb83f8971d3a5efcb10de020bb6c0aed64a1
Do not take strong variations into account if they would erase more
interesting variations.

Change-Id: I6299a64bed449a611f90eda4234af10a183958d1
Change-Id: Ia46966270418a339f8a37e8a1971a7f7dd046034
Change-Id: Ia28a7ffb826a9b6e3618b222b6ed9d0d43de308a
Added an event to represent the typing of text that is not on the
device's keyboard. ExternalText event's text is read from a buffer, that
will be filled when the event is generated.

ExternalText only exists on the simulator.

Change-Id: Ie78d2c7c2de91da986a1ce2130a5ecd123db48ee
Change-Id: I9683a8ba819b1a4aad18bcc4759160509e424d4e
Generate an ExternalText event when catching a SDL_TextInputEvent whose
text cannot be boiled down to one of the regular events.

Change-Id: I036fa2a153c8351979521d7f8cba6b62aa64604b
Change-Id: Id7f68f4dfb4727453a02437a0b824492a8c94730
The size of the ExternalText events shared buffer is now defined as the
size of the SDL_TextInputEvent 'text' field, as it should.
Also fix a wrong parameter being passed to a strlcpy.

Change-Id: I6a57d49d61fec8a009c4711efce564c65544e571
Change-Id: Iaef80fdbb6083be688fadc2b5fc515dbbd0d004c
Change-Id: I67c21d59263b7eddd7ee8ee9e61c168e6b013d13
Change-Id: I0d0d7dca0e167cfcb40f4b26d8208e12056ebf40
Change-Id: Ie2e028a5030e1b0d3f133efdde971645d5b4687b
Change-Id: Iaae5ee4292e33f923f47590ee4520bac44c5d750
Added some missing resets of the Auto and Normalize statuses

Change-Id: I5514a2566c1f6ba73d04b526402b428b2edce4b4
Only notify the delegate to the refresh the button when the status has
changed.

Change-Id: I6689d2c292ff96039a68cd1b437b18df5fb98829
Deactivate Auto status every time the range effectively changes.

Change-Id: I695b840d5e72061a73a229a6e726433660bdfdbf
Change-Id: I1553144fb45f45cbdb4e021b14ef20cb319984cc
Change-Id: I108ba8131ef2f8d3d210a769322a815121311f6b
Change-Id: I54186c0a7c12f7fb0122c0a67f4a6d0d462feb82
Change-Id: I40f61958f9e51adb376407b2a512097962979417
Change-Id: I554dd5e9b9ab3af4364ca23cde590f9e0a458ef8
Change-Id: Ia8906e27c5c28f96c87ed39f522f4b1028ad80b8
@CLAassistant
Copy link

CLAassistant commented Aug 4, 2021

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
7 out of 9 committers have signed the CLA.

✅ GabrielNumworks
✅ EmilieNumworks
✅ HugoNumworks
✅ M4xi1m3
✅ Acssiohm
✅ thePeras
✅ RedGl0w
❌ RobertaNumWorks
❌ MartijnNumworks
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@RedGl0w RedGl0w left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, however here are other changes to do / questions :

  • In the timing.h config files, LoopsPerMillisecond should be removed
  • commits should be squashed
  • I added a coding style comment
  • Since the sysTick frequency is updated too when the board clock is updated, why not making these change to usleep too ?
    the systick would need to be changed : we wouldn't want it to be called every 1ms, but every 1us (if it is possible).

ion/src/device/shared/drivers/timing.cpp Outdated Show resolved Hide resolved
Co-authored-by: Joachim Le Fournis <[email protected]>
@Acssiohm
Copy link
Author

Acssiohm commented Aug 4, 2021

For the last point , I think it's a good idea too ( but I don't know if it will affect the calculator speed, if so, I don't know if it's worth it )
For the first one, I don't think it's necessary because it's an interesting value that can be used later by others, and if it is not used, the compiler will delete it anyway
Thanks for the coding style comment
Finally I don't know if you see it , but there is still a bug, that I don't really understand

@Acssiohm
Copy link
Author

Acssiohm commented Aug 4, 2021

Also, I know I should squash the commits, but , first, I still try to understand the bug, and second I don't know how to do that

@RedGl0w
Copy link
Contributor

RedGl0w commented Aug 4, 2021

For the last point , I think it's a good idea too ( but I don't know if it will affect the calculator speed, if so, I don't know if it's worth it )

The usleep is only used by drivers, so even if there is an important speed difference, it won't be a problem for the end user (if the drivers still works).

For the first one, I don't think it's necessary because it's an interesting value that can be used later by others, and if it is not used, the compiler will delete it anyway

Even if it is an interessing value, it shouldn't be used anymore, and if we want to find it, the git history still has the value.

Finally I don't know if you see it , but there is still a bug, that I don't really understand

Yep I was looking about it.

@Acssiohm
Copy link
Author

Acssiohm commented Aug 4, 2021

The usleep is only used by drivers, so even if there is an important speed difference, it won't be a problem for the end user (if the drivers still

I am not talking about usleep, I'm talking about systick :

the systick would need to be changed : we wouldn't want it to be called every 1ms, but every 1us (if it is possible).

because we will be calling this function a thousand times more often

@RedGl0w
Copy link
Contributor

RedGl0w commented Aug 4, 2021

I am not talking about usleep, I'm talking about systick :

Yep, but you can call the systick function 1000 times more often only when usleeping, and call it every 1ms on msleep
Not sure it is a super good solution though, maybe writing in asm the usleep function would be better (and assert that the compilator doesn't optimize differently)

@Acssiohm
Copy link
Author

Acssiohm commented Aug 4, 2021

The problem is that it is not us who call the sysTick function, it's an interrupt, when it's configured, you can't change it.

@RedGl0w
Copy link
Contributor

RedGl0w commented Aug 4, 2021

The problem is that it is not us who call the sysTick function, it's an interrupt, when it's configured, you can't change it.

you can set the frequency of systick indeed (and it's configurated : when you go from high speed to low speed, when msleeping, the systick frequency is changed, in order to still tick every 1ms)

@Acssiohm
Copy link
Author

Acssiohm commented Aug 4, 2021

you can set the frequency of systick indeed (and it's configurated : when you go from high speed to low speed, when msleeping, the systick frequency is changed, in order to still tick every 1ms)

Indeed ... you're right, I didn't see your message before sending mine (deleted now) :

My bad, if a did understand the datasheet, there is maybe a systick reload value register, that you can change

and, indeed, the register ( that I was talking about ) is modified in setClockFrequency to compensate ( like you said ) .
But, what you can't change is the function called by the interrupt : isr_systick() , and it's a problem because is increment the MillisElapsed but if we make it called 1000 times more often, MillisElapsed will be incremented every microsecond, and the variable will have no sense, sometimes incremented every millisecond and sometimes every microsecond !
So you have maybe 2 solutions :

  • you can verify the frequency in the isr_systick() function, to sometimes increment MicrosElapsed ( the variable will need to be renamed ) by 1 , and sometimes by 1000 ( and in millis() you return MicrosElapsed/1000 )
  • or you can just name the variable like sysTicksElapsed and use it in usleep like microseconds, and in msleep like milliseconds , elapsed, by changing the frequency of systicks ...

@github-actions
Copy link

github-actions bot commented Aug 4, 2021

.text .rodata .bss .data
Base 686 156 bytes 274 039 bytes 180 720 bytes 1 368 bytes
Head 686 164 bytes 274 068 bytes 180 720 bytes 1 368 bytes
+ 8 bytes + 29 bytes + 0 bytes + 0 bytes
+ 0.0 % + 0.0 % + 0.0 % + 0.0 %

@Acssiohm
Copy link
Author

Acssiohm commented Aug 4, 2021

I don't understand why this problem appears, but I found where is the reason, and how to fix it.
It worked but I had to modify the LD file to make MillisElapsed one of the not discarded symbols and I don't know if it's recommended to do that.
But I wonder why MillisElapsed is discarded ( it's an important variable ) and why they could use it in millis() ( and use millis() in apps ) but we cannot use it in msleep(), if it's discarded it should be discarded everywhere , isn't it ?

@github-actions
Copy link

github-actions bot commented Aug 5, 2021

.text .rodata .bss .data
Base 686 156 bytes 274 039 bytes 180 720 bytes 1 368 bytes
Head 686 156 bytes 274 039 bytes 180 720 bytes 1 368 bytes
+ 0 bytes + 0 bytes + 0 bytes + 0 bytes
+ 0.0 % + 0.0 % + 0.0 % + 0.0 %

@Acssiohm
Copy link
Author

Acssiohm commented Aug 5, 2021

I'll just comment the last changes :

  • I removed the constant ( just commented it for now ) LoopsPerMillisecond like you said
  • I made a .bss section for the variable we are using ( because it needs to be in a .bss section, to be initialized correctly )
  • And finally I moved endTime to the top in case, changing the frequency takes time and removed volatile because endTime is not volatile ( it is not changed by an outside function, during an interrupt for example )

@Acssiohm
Copy link
Author

Acssiohm commented Aug 9, 2021

So you have maybe 2 solutions :

  • you can verify the frequency in the isr_systick() function, to sometimes increment MicrosElapsed ( the variable will need to be renamed ) by 1 , and sometimes by 1000 ( and in millis() you return MicrosElapsed/1000 )
  • or you can just name the variable like sysTicksElapsed and use it in usleep like microseconds, and in msleep like milliseconds , elapsed, by changing the frequency of systicks ...

Wich one do you think is better ?
( the first require verifying the frequency at every sysTick, the second is a make millis() impossible ... )

@Acssiohm
Copy link
Author

What did just happen ?? hundreds of commits appeared before my first one in this Pull Request and also a lot of conflicts came out !

@adriweb
Copy link
Contributor

adriweb commented Aug 25, 2021

master was updated. You can rebase your commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.