{"id":21284004,"url":"https://github.com/mesemus/softtablepwm","last_synced_at":"2025-03-15T14:43:42.543Z","repository":{"id":34932039,"uuid":"39002742","full_name":"mesemus/SoftTablePWM","owner":"mesemus","description":"Arduino Software PWM library which uses pre-filled tables to speed up timer invocation","archived":false,"fork":false,"pushed_at":"2015-07-13T12:27:11.000Z","size":168,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T03:46:19.184Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mesemus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-13T09:20:25.000Z","updated_at":"2015-07-13T09:26:15.000Z","dependencies_parsed_at":"2022-09-04T17:22:33.558Z","dependency_job_id":null,"html_url":"https://github.com/mesemus/SoftTablePWM","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesemus%2FSoftTablePWM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesemus%2FSoftTablePWM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesemus%2FSoftTablePWM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesemus%2FSoftTablePWM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mesemus","download_url":"https://codeload.github.com/mesemus/SoftTablePWM/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243746130,"owners_count":20341203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T11:13:25.444Z","updated_at":"2025-03-15T14:43:42.519Z","avatar_url":"https://github.com/mesemus.png","language":"C++","readme":"# SoftTablePWM\n\n## Look at the lowmem branch, same API and lower memory usage\n\nArduino Software PWM library for enabling PWM on all pins, supports 'set' and 'fade'.\nThe library uses pre-filled tables to minimize CPU overhead in timer invocation.\nDefault frequency of the PWM (on 16MHz processor) is 244Hz, might be increased\nvia decreasing the number of PWM levels in pwm_init function call.\n\nAlternatively change the source code of pwm_init and the interrupt on timer2 \nto occur on comparison rather than on overflow (which is once in 256 ticks) - \nif you then set the OCR2A register to lower value than 255, the timer will \nbe called more often and the frequency will increase - see \nhttps://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM for more details.\n\nThe advantage of this library:\n- lower processing overhead for the PWM\n \nThe downside: \n- memory consumption - each port (PORTB, PORTC, PORTD) needs 256 bytes of memory (allocated on the fly when a pin from that port is used).\n\nBeware that this library is not well tested, take it as a proof of concept for your own optimizations.\n\nThe library can be used with the timer2 enabled or disabled (in this case it is up to you to call pwm_cycle on a regular basis).\n\n\u003ch2\u003eUsage\u003c/h2\u003e \n\nSee fade.ino in the example directory. \n\nSimple program:\n\n```c++\n#include \u003cSoftTablePWM.h\u003e\n\n// use the timer2 interrupt handler\nINSTALL_PWM_INTERRUPT\n\nvoid setup()   {\n  // tell the library that timer2 interrupt handler is used\n  pwm_init(true);\n  \n  // will use PORTB, pin #1 (this is Arduino pin 9, \n  // see https://www.arduino.cc/en/uploads/Hacking/Atmega168PinMap2.png ) \n  int pwm_channel = pwm_add(PWM_B, 1);\n\n  // set pwm value to 128\n  pwm_set(pwm_channel, 128);\n}\n\nvoid loop() {}\n```\n\nEnjoy!\n\nms.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmesemus%2Fsofttablepwm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmesemus%2Fsofttablepwm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmesemus%2Fsofttablepwm/lists"}