ArduinoType.class.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. require_once(__DIR__.SLASH.'ReadmeType.class.php');
  3. class ArduinoType extends ReadmeType{
  4. public static function manifest(){
  5. return array(
  6. 'uid' => 'arduino',
  7. 'label' => 'Arduino',
  8. 'icon' => 'fas fa-code',
  9. 'color' => '#ffffff',
  10. 'background' => '#00979d',
  11. 'description' => 'Fichier contenant du langage arduino (proche du c++)',
  12. 'fromExtension' => array('ino'),
  13. 'toExtension' => 'ino',
  14. 'default' => '
  15. void setup()
  16. {
  17. Serial.begin(9600);
  18. Serial.println("Starting..");
  19. //pinMode(1, INPUT);
  20. //pinMode(2, OUTPUT);
  21. }
  22. void loop()
  23. {
  24. }',
  25. );
  26. }
  27. /* EDITION */
  28. public static function toHtml($resource,$sketch=null){
  29. $infos = self::manifest();
  30. return array(
  31. 'html'=>'<textarea id="content" onblur="hackpoint_resource_save_content()" class="arduino-text">'.$resource->content.'</textarea>',
  32. 'javascript' => "
  33. hackpoint_resource_mirrorify('.arduino-text',{
  34. mode : 'text/x-carduino',
  35. lineNumbers : true,
  36. theme : 'monokai',
  37. readOnly : false
  38. });
  39. "
  40. );
  41. }
  42. //Export vers un fichier brut
  43. public static function toFile($resource){
  44. $infos = self::manifest();
  45. return array(
  46. 'name'=> slugify($resource->label).'.'.$infos['toExtension'],
  47. 'content' => html_entity_decode($resource->content)
  48. );
  49. }
  50. }
  51. ?>