Edit the module

This page allows you to edit the existing module (Grove Circular LED).

Basic Information

Provide basic information of the module.

* Photo URLs that end with any one of .jpg, .jpeg, .png or that are uploaded to the Gyazo web service in the PNG format (e.g.https://gyazo.com/hogehoge) are supported.

Relevant URLs

Relevant URLs can be edited in the module page.

Card preview
Grove Circular LED
'16/7/6 20:52
Groveシステムの24連円形LEDです。

Layout information

Provide the source code of the module layout in JavaScript.

function GroveCircularLED(pin1, pin2) { this._pin1 = pin1; this._pin2 = pin2; this._name = function () { return 'GroveCircularLED(' + this._pin1 + ',' + this._pin2 + ')'; }; this._bounds = function () { return { x: -22.5, y: -22.5, width: 45, height: 45 }; }; this._print = function (g, options) { g.drawRectangle(- 15 / 2, - 15 / 2, 15, 15); g.drawCircle(- 17 / 2 - 1.5, 0, 1); g.drawCircle(+ 17 / 2 + 1.5, 0, 1); g.drawCircle( 0, - 17 / 2 - 1.5, 1); g.drawCircle( 0, + 17 / 2 + 1.5, 1); if (!options.print) { g.drawCircle(0, 0, 22.5); g.drawText(this._name(), - 22.5, + 17 / 2); } }; }
Layout
How to write code
  • First, define a function that represents this module.
  • Define methods _name, _bounds, _print within the class, where ...
  • _name method returns the name of the module for display.
  • _bounds method returns the bounding box of the module as a Rectangle instance.
  • _print method takes graphics context Graphics and printing options PrintOptions as its arguments.
More details can be found at the howto page.
Delete