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

random() without parameter like in standard Arduino API is missing. #883

Closed
ArminJo opened this issue Aug 7, 2022 · 9 comments
Closed

Comments

@ArminJo
Copy link
Contributor

ArminJo commented Aug 7, 2022

Standard Arduino programs do not compile if they use random();

E.g.

/home/runner/Arduino/libraries/NeoPatterns/src/NeoPatterns.hpp:1474:31: error: no matching function for call to 'random()'
         tRandom.Long = random();
                               ^
/home/runner/Arduino/libraries/NeoPatterns/src/NeoPatterns.hpp:1474:31: note: candidates are:
...
/home/runner/.arduino15/packages/stm32duino/hardware/STM32F1/2021.5.31/cores/maple/wirish_math.h:50:6: note: long int random(long int)
 long random(long max);

if I replace the line 50 in wirish_math.h
long random(long max);
with
long random(long max = __LONG_MAX__);
everything works fine.

Do you require a PR?

@rogerclarkmelbourne
Copy link
Owner

Where is random() implemented ?

@ArminJo
Copy link
Contributor Author

ArminJo commented Sep 17, 2022

???
long random(long howbig= LONG_MAX); introduces a default/optional parameter.

long random(long howbig) is implemented here

@rogerclarkmelbourne
Copy link
Owner

Create a PR and I will merge it, as I think its a low risk change

@ArminJo
Copy link
Contributor Author

ArminJo commented Sep 17, 2022

Done!

@rogerclarkmelbourne
Copy link
Owner

Thanks

@ArminJo
Copy link
Contributor Author

ArminJo commented Sep 17, 2022

Thank YOU for maintaining this core 🥇 .

stevstrong added a commit to stevstrong/Arduino_STM32 that referenced this issue Feb 28, 2024
* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload

* Increment size of emulated EEPROM

Defines paremeter Pages for use more than one page per bank on emulated EEPROM.

* Create TestCompile.yml

Initial version

* Update TestCompile.yml

* Changed Ethernet.h to Ethernet_STM.h

This was forgotten for this example

* Adding Adafruit Gfx library, excluding errorneous examples

* included libs excluded examples, removed debug

* more exludes

* excluded OLED_I2C examples

* Compatibility with current HEAD versions of Adafruit GFX and Adafruit BusIO.

* Adafruit_GFX_AS: Use a macro to achieve s/textsize/textsize_x/.

* Fix mistaken cast of wrong argument.

* STM32F4 backup domain registers and backup domain sram

STM32F4: update bkp.h, bkp.c add support for backup registers and backup sram.
added example in STM32F4/libraries/RTClock/examples/BkpTest

* STM32F4: RTClock - prevent clobbering if run on LSE and VBAT

updated RTClock.begin()
skip initialization of RTC running on LSE if it is already running
so that the time maintained on VBAT would not be reset

note that the change only prevents resetting RTC on LSE as only that is assured
when running on VBAT

* STM32F4 RTClock minor fix

in begin()
change:
  if(!lse_ison && RTCSEL_LSE) {
to:
  if(!lse_ison)

that RTCSEL_LSE is redundant. it suffice to test that lse_ison

* F1: fix for rogerclarkmelbourne#852: added function definition into pgmsapce.h

* USBComposite library updates: MIDI sysex support; bug fixes

* fix maple_upload dfu_address set to {runtime.ide.path} instead of {upload.dfuse_addr} or nothing rogerclarkmelbourne#854

* F1: Wire: add wire(const uint8*, int) to WireBase.h

* USB Composite 1.06 merge

* Delete unneeded file

* Update WireBase.h

added return value to write(const uint8* buf, int nr)

* Added blackpill_f411 variant

* added build options for the abilirty to select HSI clock source without a crystal - generic F103C8 only so far.

* Fix incorrect upload method for F411

* fixes rogerclarkmelbourne#883 

 random() without parameter like in standard Arduino API is missing.

* update USBComposite to 1.0.7

* Added workflow_dispatch for manual build check

This is a very handy feature :-)

* Using ln -s instead of cp

* Using ln -s instead of cp

* Fixing error: 'utoa' was not declared in this scope - see rogerclarkmelbourne#884

* Update README.md

removed invalid link to Gitter

* fix HardwareCANexample.ino

* Update wirish_digital.cpp - fix rogerclarkmelbourne#859

* fix boardPWMpins table for generic gdf103c variant

* fix boardPWMpins for generic F103c variant

* fix boardPWMpins table for generic F103C variant

* fix BOARD_NR_PWM_PIN for generic F103C variant

* Update SPI.cpp

remove some obsolete flags

* F1: DMA transfer setup function - changed parameter definition

* F1: SPI rework

* Update Print.cpp

added serial PRINTF and DBG_PRINTF

* F1: fixed generic F103 board PWM pins

* F1: added function to check if spi is in master mode

* Update SPI.cpp

- fixed DMA wait for completion in slave mode
- limited text columns to 120

* F1: SPI dmaTransferRepeat() got 2 optional parmaeters

* Rename hid-flash to hid_flash

rogerclarkmelbourne#895

* systick allows up to 4 callbacks

* F4: added PRINTF

* F4: added soft-reset nvic_sys_reset()

* F4: optimized ring_buffer

* renamed tools/macosx/hid_flash

* F4: fix heap start address for F411 boards

* F4: Wire support of alternative pins

* F4: added I2S library

* Update SPI.h

* F4: removed arduino_uip library (not used)

* F4: added Adafruit_ILI9341_STM library

* Delete AdvancedChatServer.ino

* F4: allow output pin speed selection

* F4: small changes

* F1: small changes in Adafruit_ILI9341_STM

* F1: small changes in Serasidis_VS1003B lib

* F1: removed timer setup from board init

* F1: SPI settings get initialized when creating the instance

* Update wirish.h

* Delete c_cpp_properties.json

* Update .gitignore

* Update rcc_private.h

* small fixes after previous merge

* Update SPI.h

* remove some not needed files

---------

Co-authored-by: Phonog <jeanmarc.delaplace@gmail.com>
Co-authored-by: Roger Clark <roger@rogerclark.net>
Co-authored-by: svmac <svmacx@gmail.com>
Co-authored-by: Armin <armin.arduino@gmail.com>
Co-authored-by: Kiki Lamb <miss.kiki.lamb@gmail.com>
Co-authored-by: ag88 <ag88@github>
Co-authored-by: arpruss <arpruss@gmail.com>
Co-authored-by: Tomas kovacik <nail@nodomain.sk>
Co-authored-by: board707 <ddt@jwee.ru>
Co-authored-by: purewack <54288625+purewack@users.noreply.github.com>
stevstrong added a commit to stevstrong/Arduino_STM32 that referenced this issue Feb 28, 2024
* Add files via upload

* Add files via upload

* Add files via upload

* Add files via upload

* Increment size of emulated EEPROM

Defines paremeter Pages for use more than one page per bank on emulated EEPROM.

* Create TestCompile.yml

Initial version

* Update TestCompile.yml

* Changed Ethernet.h to Ethernet_STM.h

This was forgotten for this example

* Adding Adafruit Gfx library, excluding errorneous examples

* included libs excluded examples, removed debug

* more exludes

* excluded OLED_I2C examples

* Compatibility with current HEAD versions of Adafruit GFX and Adafruit BusIO.

* Adafruit_GFX_AS: Use a macro to achieve s/textsize/textsize_x/.

* Fix mistaken cast of wrong argument.

* STM32F4 backup domain registers and backup domain sram

STM32F4: update bkp.h, bkp.c add support for backup registers and backup sram.
added example in STM32F4/libraries/RTClock/examples/BkpTest

* STM32F4: RTClock - prevent clobbering if run on LSE and VBAT

updated RTClock.begin()
skip initialization of RTC running on LSE if it is already running
so that the time maintained on VBAT would not be reset

note that the change only prevents resetting RTC on LSE as only that is assured
when running on VBAT

* STM32F4 RTClock minor fix

in begin()
change:
  if(!lse_ison && RTCSEL_LSE) {
to:
  if(!lse_ison)

that RTCSEL_LSE is redundant. it suffice to test that lse_ison

* F1: fix for rogerclarkmelbourne#852: added function definition into pgmsapce.h

* USBComposite library updates: MIDI sysex support; bug fixes

* fix maple_upload dfu_address set to {runtime.ide.path} instead of {upload.dfuse_addr} or nothing rogerclarkmelbourne#854

* F1: Wire: add wire(const uint8*, int) to WireBase.h

* USB Composite 1.06 merge

* Delete unneeded file

* Update WireBase.h

added return value to write(const uint8* buf, int nr)

* Added blackpill_f411 variant

* added build options for the abilirty to select HSI clock source without a crystal - generic F103C8 only so far.

* Fix incorrect upload method for F411

* fixes rogerclarkmelbourne#883 

 random() without parameter like in standard Arduino API is missing.

* update USBComposite to 1.0.7

* Added workflow_dispatch for manual build check

This is a very handy feature :-)

* Using ln -s instead of cp

* Using ln -s instead of cp

* Fixing error: 'utoa' was not declared in this scope - see rogerclarkmelbourne#884

* Update README.md

removed invalid link to Gitter

* fix HardwareCANexample.ino

* Update wirish_digital.cpp - fix rogerclarkmelbourne#859

* fix boardPWMpins table for generic gdf103c variant

* fix boardPWMpins for generic F103c variant

* fix boardPWMpins table for generic F103C variant

* fix BOARD_NR_PWM_PIN for generic F103C variant

* Update SPI.cpp

remove some obsolete flags

* F1: DMA transfer setup function - changed parameter definition

* F1: SPI rework

* Update Print.cpp

added serial PRINTF and DBG_PRINTF

* F1: fixed generic F103 board PWM pins

* F1: added function to check if spi is in master mode

* Update SPI.cpp

- fixed DMA wait for completion in slave mode
- limited text columns to 120

* F1: SPI dmaTransferRepeat() got 2 optional parmaeters

* Rename hid-flash to hid_flash

rogerclarkmelbourne#895

* systick allows up to 4 callbacks

* F4: added PRINTF

* F4: added soft-reset nvic_sys_reset()

* F4: optimized ring_buffer

* renamed tools/macosx/hid_flash

* F4: fix heap start address for F411 boards

* F4: Wire support of alternative pins

* F4: added I2S library

* Update SPI.h

* F4: removed arduino_uip library (not used)

* F4: added Adafruit_ILI9341_STM library

* Delete AdvancedChatServer.ino

* F4: allow output pin speed selection

* F4: small changes

* F1: small changes in Adafruit_ILI9341_STM

* F1: small changes in Serasidis_VS1003B lib

* F1: removed timer setup from board init

* F1: SPI settings get initialized when creating the instance

* Update wirish.h

* Delete c_cpp_properties.json

* Update .gitignore

* Update rcc_private.h

* small fixes after previous merge

* Update SPI.h

* remove some not needed files

---------

Co-authored-by: Phonog <jeanmarc.delaplace@gmail.com>
Co-authored-by: Roger Clark <roger@rogerclark.net>
Co-authored-by: svmac <svmacx@gmail.com>
Co-authored-by: Armin <armin.arduino@gmail.com>
Co-authored-by: Kiki Lamb <miss.kiki.lamb@gmail.com>
Co-authored-by: ag88 <ag88@github>
Co-authored-by: arpruss <arpruss@gmail.com>
Co-authored-by: Tomas kovacik <nail@nodomain.sk>
Co-authored-by: board707 <ddt@jwee.ru>
Co-authored-by: purewack <54288625+purewack@users.noreply.github.com>
@ArminJo
Copy link
Contributor Author

ArminJo commented Mar 15, 2024

@SteveStrong @rogerclarkmelbourne Is there any reason, why the PR is not merged now?

@stevstrong
Copy link
Collaborator

which PR?

@ArminJo
Copy link
Contributor Author

ArminJo commented Mar 15, 2024

Sorry I had "Tomaten auf den Augen".
it was PR #889.
I was searching for it in order to delete my local fork and I have not found it, since I looked at the wrong place.
Thanks again for maintaining!

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

No branches or pull requests

3 participants