2019年12月21日土曜日

ソースコードの挿入実験

どうやったら良いのか分からなかったのでググったらQiitaにGoogle-code-prettifyというのがあったので、早速実験!
無事実行成功! ただ、これだけでは足りなかったので、以下のCSS(元のページ)を追加して、max-heightを加えて縦横スクロールを追加。
これでやっとやりたいことが出来るようになった、、、。
  1. /*
  2. Google code-prettify
  3. */
  4. pre.prettyprint
  5. {
  6. border: 1px solid #cccccc !important;
  7. line-height: 1.5em;
  8. overflow: auto;
  9. width: auto;
  10. max-height: 600px;
  11. padding: 2em !important;
  12. }
  13. pre.prettyprint > ol.linenums
  14. {
  15. padding-left: 2em;
  16. }
  17. pre.prettyprint > ol.linenums > li
  18. {
  19. border-left: 1px solid #cccccc;
  20. margin-bottom: 0;
  21. }
  22. pre.prettyprint > ol.linenums > li.L0,
  23. pre.prettyprint > ol.linenums > li.L1,
  24. pre.prettyprint > ol.linenums > li.L2,
  25. pre.prettyprint > ol.linenums > li.L3,
  26. pre.prettyprint > ol.linenums > li.L4,
  27. pre.prettyprint > ol.linenums > li.L5,
  28. pre.prettyprint > ol.linenums > li.L6,
  29. pre.prettyprint > ol.linenums > li.L7,
  30. pre.prettyprint > ol.linenums > li.L8,
  31. pre.prettyprint > ol.linenums > li.L9
  32. {
  33. list-style-type: decimal;
  34. }
  35. pre.prettyprint > ol.linenums > li.L1,
  36. pre.prettyprint > ol.linenums > li.L3,
  37. pre.prettyprint > ol.linenums > li.L5,
  38. pre.prettyprint > ol.linenums > li.L7,
  39. pre.prettyprint > ol.linenums > li.L9
  40. {
  41. background-color: transparent;
  42. }
  43. pre.prettyprint > ol.linenums > li span:first-child
  44. {
  45. padding-left: 1em;
  46. }
  47. pre.prettyprint > ol.linenums > li span:last-child
  48. {
  49. padding-right: 1em;
  50. }
  51. /* plain text */
  52. pre.prettyprint .pln { color: #cccccc; }
  53. /* string content */
  54. pre.prettyprint .str { color: #cccc33; }
  55. /* a keyword */
  56. pre.prettyprint .kwd { color: #00cc00; }
  57. /* a comment */
  58. pre.prettyprint .com { color: #cc3366; }
  59. /* a type name */
  60. pre.prettyprint .typ { color: #00cc00; }
  61. /* a literal value */
  62. pre.prettyprint .lit { color: #3399cc; }
  63. /* punctuation, lisp open bracket, lisp close bracket */
  64. pre.prettyprint .pun,
  65. pre.prettyprint .opn,
  66. pre.prettyprint .clo
  67. { color: #cccccc; }
  68. /* a markup tag name */
  69. pre.prettyprint .tag { color: #3399cc; }
  70. /* a markup attribute name */
  71. pre.prettyprint .atn { color: #00cc00; }
  72. /* a markup attribute value */
  73. pre.prettyprint .atv { color: #cccc33; }
  74. /* a declaration; a variable name */
  75. pre.prettyprint .dec,
  76. pre.prettyprint .var
  77. { color: #00cc00; }
  78. /* a function name */
  79. pre.prettyprint .fun { color: #cc66cc; }
  80.  
  1. /*
  2. Deep Sleep with External Wake Up
  3. =====================================
  4. This code displays how to use deep sleep with
  5. an external trigger as a wake up source and how
  6. to store data in RTC memory to use it over reboots
  7. This code is under Public Domain License.
  8. Hardware Connections
  9. ======================
  10. Push Button to GPIO 33 pulled down with a 10K Ohm
  11. resistor
  12. NOTE:
  13. ======
  14. Only RTC IO can be used as a source for external wake
  15. source. They are pins: 0,2,4,12-15,25-27,32-39.
  16. Author:
  17. Pranav Cherukupalli
  18. */
  19. #include "esp_deep_sleep.h"
  20. #define BUTTON_PIN_BITMASK 0x8004 // GPIOs 2 and 15
  21. //#define BUTTON_PIN_BITMASK BIT64(GPIO_NUM_34)|BIT64(GPIO_NUM_36)// GPIOs 34 and 36
  22. unsigned long time0;
  23. unsigned long time1;
  24. RTC_DATA_ATTR int bootCount = 0;
  25. /*
  26. Method to print the reason by which ESP32
  27. has been awaken from sleep
  28. */
  29. void print_wakeup_reason(){
  30. time0 = micros();
  31. esp_sleep_wakeup_cause_t wakeup_reason;
  32. wakeup_reason = esp_sleep_get_wakeup_cause();
  33. switch(wakeup_reason)
  34. {
  35. case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
  36. case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
  37. case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
  38. case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break;
  39. case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break;
  40. default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;
  41. }
  42. time1 = micros();
  43. Serial.print("==>print_wakeup_reason() : ");
  44. Serial.println( time1 -time0 );
  45. }
  46. /*
  47. Method to print the GPIO that triggered the wakeup
  48. */
  49. void print_GPIO_wake_up(){
  50. time0 = micros();
  51. int GPIO_reason = esp_sleep_get_ext1_wakeup_status();
  52. time1 = micros();
  53. Serial.print("GPIO that triggered the wake up: GPIO ");
  54. Serial.print( GPIO_reason );
  55. Serial.print( " : " );
  56. Serial.println((log(GPIO_reason))/log(2), 0);
  57. Serial.print("==> print_GPIO_wake_up() : ");
  58. Serial.println( time1 - time0 );
  59. }
  60. void setup(){
  61. Serial.begin(115200);
  62. delay(1000); //Take some time to open up the Serial Monitor
  63. //Increment boot number and print it every reboot
  64. ++bootCount;
  65. Serial.println("Boot number: " + String(bootCount));
  66. // Following 4 lines from http://wakwak-koba.hatenadiary.jp/entry/20170219/p1
  67. // to make deep sleep to 4 micro amp consumption, otherwise 27 micro amp?
  68. esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
  69. esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
  70. esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
  71. esp_deep_sleep_pd_config(ESP_PD_DOMAIN_MAX, ESP_PD_OPTION_OFF);
  72. //Print the wakeup reason for ESP32
  73. print_wakeup_reason();
  74. //Print the GPIO used to wake up
  75. print_GPIO_wake_up();
  76. /*
  77. First we configure the wake up source
  78. We set our ESP32 to wake up for an external trigger.
  79. There are two types for ESP32, ext0 and ext1 .
  80. ext0 uses RTC_IO to wakeup thus requires RTC peripherals
  81. to be on while ext1 uses RTC Controller so doesnt need
  82. peripherals to be powered on.
  83. Note that using internal pullups/pulldowns also requires
  84. RTC peripherals to be turned on.
  85. */
  86. //esp_deep_sleep_enable_ext0_wakeup(GPIO_NUM_15,1); //1 = High, 0 = Low
  87. //If you were to use ext1, you would use it like
  88. esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH);
  89. //Go to sleep now
  90. Serial.println("Going to sleep now");
  91. delay(1000);
  92. esp_deep_sleep_start();
  93. Serial.println("This will never be printed");
  94. }
  95. void loop(){
  96. //This is not going to be called
  97. }

0 件のコメント:

RM Noise

最近Galaxyの携帯のCMで風のノイズ除去をしているシーンが気になっていて、「AIで処理すれば、ノイズ除去性能は上がるのでは?」なんて思いながら、 AIのopen source?の Hagging face をブラブラしていましたら、何故かFacebookで RM noize ...