JavaScript Classes

Aug 5, 2020

JavaScript classes were introduced in ECMAScript 2015(ES6). They are primarily syntactical sugar over JavaScript’s existing prototype based inheritance.

class Rectangle {
    constructor(width, height) {
        this.width = width;
        this.height = height;
    }

    area() {
        return (this.width * this.height);
    }
}

The constructor method is a special method for creating and initializing an object created with a class.

A constructor can use the super keyword to call the constructor of the super class.

Sub classes can be created with extends keyword.

class Square extends Rectangle {
    constructor(width, height) {
        super(width, height);
    }

    area() {
        let result = super.area();
        console.log("Area of square is ", result);
    }
}

References

Categories : JavaScript   ES6

Lego Mindstroms EV3

Jul 22, 2020

'Falcon' Lego Mindstorms EV3 Robot by Kyle Markland"'Falcon' Lego Mindstorms EV3 Robot by Kyle Markland" by dluders is licensed under CC BY 2.0

Lego Mindstroms EV3 is a hardware and software structure produce by Lego for development of programmable robots based on Lego building blocks.

The Lego Mindstorms EV3 is the third generation Lego Mindstorms product. The set includes motors, sensors, the EV3 programmable brick, 550+ Lego Technic elements and a remote control. The EV3 can be controlled by smart-devices.

Main parts of EV3 are listed below,

EV3 Brick

Programmable, intelligent brick serves as the heart and brain of EV3 robots. It has input and output ports, button interface, display. Its powered by AA batteries or EV3 Rechargeable DC battery. It has ARM 9 processor with Linux-based operating system.

Large Servo Motor

The EV3 Large Servo Motor is a powerful motor that uses tacho feedback for precise control to within one degree of accuracy.

Medium Servo Motor

The EV3 Medium Servo Motor is great for lower-load, higher speed applications and when faster response times and a smaller profile are needed in the robot’s design.

Color Sensor

The digital EV3 Color Sensor distinguishes between eight different colors. It also serves as a light sensor by detecting light intensities.

Touch Sensor

The analog EV3 Touch Sensor is a simple but exceptionally precise tool that detects when its front button is pressed or released and is able to count single and multiple presses.

Infrared Sensor

The digital EV3 Infrared Seeking Sensor detects proximity to the robot and reads signals emitted by the EV3 Infrared Beacon.

Remote Infrared Beacon

This has been designed for use with the EV3 Infrared Seeker Sensor. The beacon emits an infrared signal which the sensor can track. The beacon can also be used as a remote control for the EV3 brick through signals sent to the infrared sensor.

References:

Categories : Lego   Robotics   EV3

XInput and DirectInput

Jul 13, 2020

File:Logitech Rumblepad F510, 1.jpg"File:Logitech Rumblepad F510, 1.jpg" by Morn is licensed under CC BY-SA 3.0

XInput is an API that allows applications to receive input from the Xbox Controller for Windows. The DirectInput API is used to process data from a joystick, or other game controller. Use of legacy DirectInput is not recommended, and DirectInput is not available for Windows Store apps.

Microsoft introduced XInput as a new API with better support for advanced controllers. Around 2011 Microsoft deprecated DirectInput, Some controllers have a hardware switch to toggle modes.

“Xbox 360 Controller Emulator” program could be used to translate XInput calls to DirectInput calls - supports old, non-XInput compatible GamePads.

References:

Categories : Games   Controller

GPIO - General Purpose Input Output

Jul 13, 2020

PI GPIO reference board on a Rasperry Pi Rev 1"PI GPIO reference board on a Rasperry Pi Rev 1" by Low Voltage Labs is licensed under CC BY-SA 2.0

A powerful feature of the Raspberry Pi is the row of GPIO (general-purpose input/output) pins along the top edge of the board. A 40-pin GPIO header is found on all current Raspberry Pi boards (unpopulated on Pi Zero and Pi Zero W). Prior to the Pi 1 Model B+ (2014), boards comprised a shorter 26-pin header. Any of the GPIO pins can be designated (in software) as an input or output pin and used for a wide range of purposes.

References:

Categories : Electronics   Raspberry Pi

Holy Grail CSS Layout

Jul 10, 2020

File:HolyGrail.svg"File:HolyGrail.svg" by David Lark is licensed under CC BY-SA 4.0

Holy Grail is a layout pattern that’s very common on the web. It consists of a header, a main content area with fixed-width navigation on the left, content in the middle and a fixed-width sidebar on the right and then a footer.

It is commonly desired and implemented, but for many years, the various ways in which it could be implemented with available technologies all had drawbacks. Because of this, finding an optimal implementation was likened to searching for the elusive Holy Grail.

Below example is taken from In Search of the Holy Grail

<div id="header"></div><div id="container">
  <div id="center" class="column"></div>
  <div id="left" class="column"></div>
  <div id="right" class="column"></div></div><div id="footer"></div>
body {
  min-width: 550px;      /* 2x LC width + RC width */
}
#container {
  padding-left: 200px;   /* LC width */
  padding-right: 150px;  /* RC width */
}
#container .column {
  position: relative;
  float: left;
}
#center {
  width: 100%;
}
#left {
  width: 200px;          /* LC width */
  right: 200px;          /* LC width */
  margin-left: -100%;
}
#right {
  width: 150px;          /* RC width */
  margin-right: -150px;  /* RC width */
}
#footer {
  clear: both;
}
/*** IE6 Fix ***/
* html #left {
  left: 150px;           /* RC width */
}

References:

Categories : CSS   HTML