Categories
INSTAGRAM PHOTOGRAPHY SMARTPHONES TUTORIALS

What Does Aspect Ratio Mean In Photography?

Aspect Ratio is one of the important parameter in photography that determines the quality of a photograph. In this article, we will try to understand what an Aspect Ratio means in photography and how to chose the best Aspect Ratio while taking photographs.

You might be taking your photographs using a dedicated Photographic camera or by using a simple smartphone camera, but what makes a real difference in how these images evolve ultimately depends on the Aspect Ratio of these images. So let us dwell in detail into understanding the concept of aspect ratios in pictures and how you can determine which is the best aspect ratio to use in your pictures, depending on the type of pictures you want to take.

When you look into any photograph, you will notice that it is composed of a two dimensional capture of a moment in time and place. This two dimensional aspect of the subject of the image is then captured and stored in your photograph in two dimension as well. In other words, your photograph has two dimensions associated with it, its width and its height. It is the ratio of this width and height of a photograph that is called its Aspect Ratio.

An image representation describing the Aspect Ratio of a photograph to be the ratio of width to height.
Representation Of Aspect Ratio In Photography

There exists many different aspect ratios used in photography these days such as the 4:3 Aspect Ratio, 3:2 Aspect Ratio or 16:9 Aspect Ratios. In addition to these, photographers sometimes also use aspect ratios such as 5:3, 5:4 and 1:1 as well for medium or large photographs.

When to use 1:1 Aspect Ratio

With the emergence of various social media platforms such as instagram, facebook or twitter, the unusual aspect ratio of 1:1 has become popular these days. With this kind of aspect ratio, users can record video or capture images while holding the smartphone vertically while still be able to view the resulting video or images horizontally without losing any information in the image.

1:1 Aspect Ratio usually used my Instagram, Facebook, Twitter etc.

When to use 4:3 Aspect Ratio

4:3 Aspect ratios are the most commonly used aspect ratio in TVs and films. However, even devices such as iPad and other tablets use 4:3 aspect ratio displays so images taken with aspect ratio 4:3 will view better on ipads and other tablets when compared to other ratios.

4:3 Aspect Ratio usually used by iPad, TVs

When to use 16:9 Aspect Ratio

The 16:9 Aspect Ratio has become a recent standard usually found in high definition pictures and videos that can be best viewed on a HD screen, TVs and monitors. In a HD image with higher resolution, we can get detailed information in an image even when we zoom into the picture.

16:9 Aspect Ratio usually used in HD TV, HD Monitors & HD Displays

When to use 9:16 Aspect Ratio

Just like 16:9 aspect ratio used in HD images and videos, there emerged its inverted 9:16 Aspect Ratio that was popularized by Snapchat in its “stories” feature. This is an aspect ratio where in user is expected to record videos in portrait mode (using their smartphone vertically instead of horizontally) and viewed in portrait mode (vertically) as well. With the “stories” feature of Snapchat becoming popular, this ratio has been adopted by other social networks such as Facebook and Instagram as well.

9:16 Aspect Ratio used in Snapchat, Instagram stories

With so many new media applications becoming popular on smartphones, the aspect ratios of photography and videos keep on evolving, so this is not an all inclusive list but something that keeps on emerging as the time progresses.

Categories
100DaysOfCode EMBEDDED PROGRAMMING PROGRAMMING PYTHON RASPBERRY PI TUTORIALS

Python Program To Add Two Numbers

In this article, we will look at how to write a Python program to add two numbers. This is a very simple Python program that is suitable for even a beginner in Python programming to work on it for getting hands on practice with Python.

In order to add two numbers in Python program, we need to first break down the problem into the following steps:

Breakdown of the problem of Adding two numbers

  1. Receive the first input number from the user and store it in a Python variable.
  2. Receive the second input number from the user and store it in another Python variable.
  3. Add the two numbers by adding the two Python variables using a Python statement (Learn about Python statement here)
  4. Store the final result in another Python variable called “result”
  5. Print the value of the “result” variable.

In the above breakdown of the problem, you will notice that the Python program we will be written in such a way that the two numbers that need to be added will not be hard coded directly into the program itself but instead is written in a generic way such that we prompt the user to enter these two input values every time the Python program to add two numbers is run. This type of programming approach is often called general programming as the program is generic enough to receive any two different values each time it is run.

Pseudo-code To Add Two Numbers Using Python Programming Language

num1 = Receive First Input Number From The User
num1 = Receive Second Input Number From The User
result = (num1) Added to (num2)
Print the (result) on the screen

We can see from the above psuedo code that this is a simple program that receives two numbers from the user, adds them and print their results back on the screen. The above pseudo code gives us a nice little framework on how to write our program. The same pseudo-code can now be used to write a program to add two numbers using any programming language and not just Python!

Now that we have our problem broken down and pseudo code written, it is time for us to replace the pseudo code with actual Python programming code instructions.

Python Program To Add Two Numbers And Print Its Result

Fire up your Python IDLE interpreter and start typing in the code along with me for you to be able to understand this program better:

Python 3.5.2 (default, Oct  8 2019, 13:06:37) 
 [GCC 5.4.0 20160609] on linux
 Type "copyright", "credits" or "license()" for more information.
>>>

Once in our python interpreter, let us start typing in our Python program commands. The first thing we need to do according to the pseudo code written above is the receive the first input number from our user. In Python program, the instruction code to be used to receive a value from its user is by calling the input() function. Input function will accept a string as its parameter that will be displayed to the program user when the program is run. So, with this knowledge, our first line of the Python program to add two numbers will be:

>>> num1 = input('Enter the first number\n')
Enter the first number
10
>>> 

As you can see from the above code block, we have used the input() function to prompt our program user with the string “Enter the first number“. We are also saving the value entered by the user to a Python variable called num1.

The input function will then prompt with the above string and wait until the user enters a number. In the above code snippet, I had entered a value of 10 which is now stored in the variable num1.

In a similar way, we will write the next line of code which will prompt the user to enter a second input number that is to be added to the first number. This is achieved with the following piece of code:

>>> num2 = input('Enter the second number\n')
Enter the second number
20
>>> 

Again over here, I have entered my second number as 20 when prompted.

Now that we have the two numbers in our Python variables num1 and num2, it is time add them to get the final result that we are going to store in our third Python variable called result. This is achieved using the following Python statement:

>>> result = int(num1) + int(num2)
>>>

So from the above python code, we have now added the numbers num1 and num2 using the Python arithmetic operator “+” and the typecast operator called “int()“. We had to use the typecast operator int because by default all inputs from the user into a python program will be interpreted and stored as a string. We can check this by issuing the following command in the interpreter:

>>> print(num1)
10
>>> type(num1)
<class 'str'>
>>> 

So, by calling the typecast operator int, we are converting this string value to an integer value.

>>> type(int(num1))
<class 'int'>
>>> 

finally stored the end result in a new variable called result. Since we have not issued a Python command to print the value of result, nothing gets printed on the IDLE prompt yet. So, the final step is exactly that. To print the value of the result variable onto the screen. This is achieved using another Python function called the print function.

>>> print (result)
30
>>>

Here is the full program that we can store in a file called add2num.py and run it using the command python3 add2num.py everytime we want to add any two numbers!

num1 = input('Enter the first number\n')
num2 = input('Enter the second number\n')
result = int(num1) + int(num2)
print (result)

This concludes our Python program to add two numbers.

Additional Side Notes On Python Programming Language:

Python is an interpreted programming language that gets interpreted and executed on the fly and hence the program written in Python do not need to be compiled like in the case of a C or Java programming language.

Categories
ARM ARM ARCHITECTURE ARM PROGRAMMING COMPUTER HARDWARE ELECTRONICS EMBEDDED EMBEDDED COMPUTERS EMBEDDED PROGRAMMING HARDWARE PROGRAMMING PYTHON RASPBERRY PI RASPBERRY PI PROJECTS TUTORIALS

Blinking An LED Connected To GPIO Pin Of Raspberry Pi Using Python

Introduction

If you are just getting started with Raspberry Pi, connecting a simple LED to one of the GPIO pins of a Raspberry Pi and controlling it using software program that you write will give you a very good grasp of how a computer hardware and its program works internally. You will realize how you can control various aspects of a computer hardware using software, how a computer works at the bit level, how to write Python programs to control hardware and more.

In summary, working on getting an led connected to a GPIO pin of your Raspberry Pi will help you in understanding the fundamentals of a computer architecture and computer science in general.

Raspberry Pi 3B

What You Will Learn From This Project?

Connecting an LED to the GPIO pins of a Raspberry Pi to control it is a simple Beginner Raspberry Pi Project that lets you learn more about:

  • Raspberry Pi hardware internals
  • General Purpose Input/Output (GPIO) pins of a Raspberry Pi
  • Raspberry Pi Register Set
  • Ohm’s Law
  • Python Programming
  • Python Library – Raspberry Pi GPIO library
  • The working of an Light Emitting Diode (LED)

What Hardware Is Required To Set Up A Blinking LED Project?

This a very simple, beginner friendly Raspberry Pi project that can be set up by anyone with minimal hardware or software knowledge. The hardware components required to set up this blinking LED project is also quite minimal. You need the following hardware components available with you to get it going:

  • Raspberry Pi Module
  • Solderless Breadboard
  • Keyboard
  • Monitor
  • Raspberry Pi Power Supply
  • SD Card with working Raspbian OS
  • Jumper wires for rigging up the circuit
  • LED
  • Resistor (1K Ohm)
  • Multimeter

Theory Behind How The Raspberry Pi Blinking LED Project Work

When you look at the Raspberry Pi board, you will see a bunch of pins protruding out. Among these, there is a row of 40 pins located on one side of the board as shown in the image below.

If you look closely enough in the above image, you will notice the label “GPIO” written right under it. These pins are called the GPIO pins or General Purpose Input Output pins. What the name GPIO implies is that these pins do not have any fixed functionality within the board and hence can be used for general purposes. It means that we can connect our LED into one of these pins and can turn it ON or OFF using these pins. But how?

How to control the Raspberry Pi GPIO pins programmatically?

Raspberry Pi 3 board runs on Broadcom’s ARM CPU chipset BCM2837. Among many other things, this processor chipset has a built in GPIO controller aka General Purpose Input Output controller. The 40 GPIO pins header shown in figure 1 is connected to 40 controllable pins of the GPIO controller. Now, we can control each of these pins individually by programming the appropriate registers inside this GPIO controller.

To understand how to program each of these pins using GPIO controller, we need to look into the Technical Reference Manual or datasheet of the Broadcom ARM chipset BCM2837.

In the BCM2837 SOC (System On Chip aka CPU) datasheet linked above, if we jump into page 89 we come across a dedicated chapter talking about General Purpose Input Output (GPIO). If we go through this chapter, we can learn about all the GPIO registers available and figure out the GPIO registers we need to program to turn ON or OFF the LED we are going to connect to the Raspberry Pi 3 GPIO pins.

As the name implies, GPIO pins can be configured as either an Input pin or an Output pin. When we configure a GPIO pin as an input pin, we are sending data bit (either 0 or 1) into the Raspberry Pi BCM2837 SOC i.e. data signal is sent from outside the board to inside the board (hence the name input). On the other hand, if we configure the Raspberry Pi GPIO pin as an output pin, the board will send the data bit signal (either 0 or 1) from inside the board to the outer world where any device connected to it will receive this signal.

So, if we want to control an LED that is connected to one of the Raspberry Pi’s GPIO pin, we need to configure that pin as a GPIO OUT pin (aka output pin) so that we can send an electrical signal from the Raspberry Pi board to the external LED connected to this pin.

The configuration of a GPIO pin to be an INPUT or OUTPUT pin is controlled by programming the GPIO Controller Register called GPIO Function Select Register (GPFSELn) where n is the pin number.

So for example, if we choose to use the GPIO8 pin to control the LED, i.e. we connect our LED to GPIO 8 pin, we need to program the GPFSEL register for the GPIO 8 pin and configure it as an Output pin. When we check the datasheet at page 91 and 92, we notice that GPIO pin is configured by setting the bits 26 to 24 in the GPFSEL register (that is field name FSEL8). And from the datasheet, we also find that to set the pin as an output pin, we need to set its value as 001 i.e. bit 26 is set to 0, bit 25 is set to 0 and bit 24 is set to 1.

So, if we can somehow set these values in the GPFSEL register using a programming language such as Python, we will be able to start controlling the LED connect to this pin!

If this is all overwhelming to you, do not worry. We will not have to scratch our head a lot for now as we can simply make use of Raspberry Pi’s GPIO Python library that helps us in making most of this work for us. But I just wanted to explain to you as to what this GPIO Python library is doing under the hood.

How To Connect An LED To Raspberry Pi GPIO?

Designing The Circuit

In order to connect an LED to GPIO pin 8 of Raspberry Pi, we need to first design and understand how the circuit is going to work.

Can we connect an LED directly to a Raspberry Pi GPIO pin without a resistor?

The answer is No. Raspberry Pi provides 3.3 Volts of power on its GPIO output pin according to Raspberry Pi datasheet specification. However, if we take a look at a standard LED, we notice that it normally operates at a much lower voltage. If we look at an LED specification, we notice that a typical LED usually operates at just 1.7 Volts and draws 20 mA. So, if we need to connect this LED to the GPIO pin of our Raspberry Pi, we need to bring down the voltage delivered by the pin to our LED to operate at or under 1.7V. How to do that? We connect a resistor in series with our LED so that the 3.3 Volts GPIO output of Raspberry Pi gets split between the resistor and our LED. By choosing a right value of the resistor such that it consumes 1.6 Voltage, we can ensure that LED finally gets only 1.7 Volts.

Calculating the resistor value to connect with LED and Raspberry Pi GPIO

In order to calculate the value of resistor that we should be using, we make use of the Ohm’s Law.

Ohm’s Law is defined using the equation:

V = I/R where V is the voltage, I is the current and R is the resistor value.

So, if we want to have V=1.6 Volts consumed by our resistor so that the current coming from GPIO pin is at I=20 mA, we need to connect a resistor whose value is:

1.6 = (20 mA)/R

or R = 80 Ohms (or approx 100 Ohms)

So, we choose a resistor of value 100 Ohms connected in series with our resistor to ensure that we only get 1.7 Volts and 20 mA of current, the optimum operating values as required by our LED.

A 100 Ohm resistor is identified by the color bands: Brown, Black & Brown.

Hook up the led through 100 Ohm resistor to GPIO 8 pin of Raspberry Pi as shown in the figure below:

Note that when you are hooking up the LED, the terminal pin that is longer is positive. Once you have connected as shown in the figure, it is now time to program the Raspberry Pi GPIO controller to start controlling the LED to turn ON or OFF.

We will be using Python to program our Raspberry Pi GPIO controller. Now, the simplest way to program this is by making use of the Python GPIO library.

To install the Python Raspberry Pi GPIO module, open up your linux terminal and type the following command.

sudo apt-get install python-rpi.gpio python3-rpi.gpio

Now the above command will install the required Python GPIO library module onto our Linux development machine. Once successfully installed, It is now time to start programming the Raspberry Pi GPIO controller.

We will be toggling our GPIO pins at 1 second intervals such that our LED will turn ON and OFF forever until the Python program we write will be terminated i.e., we will be running the code to perform infinite loop of toggling the GPIO 8 pin ON and OFF.

Create a new file on your computer by typing the following command in the terminal:

touch blinky.py

This should create our new program file called blinky.py

Open up this file using nano editor by typing the following command in the terminal:

nano blinky.py

Now that the file is opened, it is time to start writing our program to control the GPIO Pin 8 using Python GPIO library module.

First thing first, we will import the Python GPIO library module using command:

import RPi.GPIO as GPIO

Next, we will import python time library to perform 1 sec sleep operation between each GPIO toggle

from time import sleep

Next, we need to configure our GPIO library to use our GPIO physical pin numbering as seen on the Raspberry Pi board physically:

GPIO.setmode(GPIO.BOARD)

This ensures that when we say GPIO pin 8 in the program, it actually maps to the GPIO Pin 8 seen on the Raspberry Pi board.

Next, configure GPIO pin 8 to be a GPIO Out pin and set its initial output value to be low:

GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW)

Finally we will start an infinite loop in Python such that we turn ON the GPIO 8 (by setting it HIGH) or turn it OFF (by setting it LOW) after every 1 second delay. This is achieved using the program below:

while True: # Infinite loop
    GPIO.output(8, GPIO.HIGH) # Turn GPIO 8 pin on
    sleep(1)                  # Delay for 1 second
    GPIO.output(8, GPIO.LOW)  # Turn GPIO 8 pin off
    sleep(1)                  # Delay for 1 second

That’s it, this should be all the program that we need to type in our blinky.py file and run it using the command:

python3 blinky.py

This should start turning your LED ON and OFF every second!

Here is the full code for your reference:

import RPi.GPIO as GPIO
from time import sleep

GPIO.setmode(GPIO.BOARD)
GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW)

while True: # Infinite loop
    GPIO.output(8, GPIO.HIGH) # Turn GPIO 8 pin on
    sleep(1)                  # Delay for 1 second
    GPIO.output(8, GPIO.LOW)  # Turn GPIO 8 pin off
    sleep(1)                  # Delay for 1 second

This should conclude our tutorial on how to get a simple LED connected to a General Purpose Input/Output (GPIO) pin turning ON and OFF using a Python program that makes use of Python Raspberry Pi GPIO library. There can be many variants to this such as using other GPIO pins, connecting more than one LEDs to multiple GPIO pins and controlling them all in different ways to display interesting patterns on the LEDs. If we are even more curious, we can also figure out a way to control the BUILT-IN LEDs that are already present on our Raspberry Pi boards to bypass their current usage and be used for by own programs for our purposes.

We will dwell into these and many other interesting ways to make use of our Raspberry Pis to understand and learn more about the computer hardware, its architecture and much more in our future articles.

Categories
Android Filesystem HARDWARE SMARTPHONES TUTORIALS

What Is Jmtpfs In Linux & How To Use It? Explained

Jmtpfs is a combination of FUSE (Userspace Filesystem) and MTP (Media Transfer Protocol) stack integrated together to form a filesystem tool. The jmtpfs tool is then used to mount your smartphones or other handheld devices onto your Linux computer so that you can browse the content of your smartphone or handheld device directly from your computer.

Jmtpfs filesystem stack in a Linux computer

What Is A FUSE Filesystem?

FUSE filesystem stands for Userspace Filesystem. In general cases, when you need to create your own filesystems, you need to have knowledge of the Operating System (OS) kernel and block storage device drivers. This would restrict the development of new filesystems to only kernel developers.

In Linux, in order to overcome this, a new type of filesystem model was introduced called the FUSE file system. In a FUSE filesystem, you will make use of a pre-written generic FUSE Linux kernel module, which you as a userspace developer need not have to modify. In addition to this, you will also make use of a pre-written FUSE userspace library that would provide the required API interfaces to the FUSE kernel modules form the userspace.

Using these two modules, it is now possible for the userspace developers to write their own filesystems by inserting the FUSE kernel module into their machine’s operating system and then writing their own filesystem with the help of FUSE library modules.

Such developed FUSE filesystems will place the files and directories exposed by the filesystem in the userspace region of the OS which is accessible by even non privileged users.

What Is Media Transfer Protocol (MTP)?

Media Transfer Protocol (MTP) is a type of protocol used to transfer media files such as audio files, videos files or image files at the file level rather than at the storage level. This protocol became a USB standard to transfer media files between a computer and a USB device.

The main reason why we would use an MTP protocol instead of the USB standard Mass Storage protocol is that when you use a Media Transfer Protocol (MTP) to transfer file, the whole file is transferred from the device to the computer or vice versa. So, the entire transfer of file happens as a single unit, hence transactional. In this way, both the device and host can continue to access the same file simultaneously, which is not possible when using a USB Mass Storage Device Class (MSC) protocol.

In case of an USB MSC protocol, when a USB mass storage device such as a music player is mounted on to a computer, the music player loses control over the files which is stored within itself and is taken over by the host computer’s filesystem. In this situation, the host computer can modify the content of the files and the USB device has no way to prevent it. This may lead to host computer corrupting the files of the USB mass storage device! But this situation is not at all possible when we use an MTP protocol due to its transactional file transfer nature. Hence MTP protocol is preferred over a USB MSC protocol.

JMPTFS tool makes use of both FUSE filesystem and the USB MTP protocol to mount the content of your smartphone onto a local directory on your computer, thereby giving access to the file contents of your smartphone even when you are a non privileged user.

How To Use Jmtpfs tool To Transfer Files From Your Smartphone

In order to use jmtpfs, you first need to create a local directory such as ‘myPhone’ in your computer. Next, you connect your Android or any other smartphone to your computer using an USB cable. Then by issuing the console command ‘jmtpfs myPhone’ you can mount the content of your smartphone onto your mount directory ‘myPhone’. In other words, after issuing the command, you will be able to browse the content of your smartphone within the mount directory ‘myPhone’ just like any other files and folders of your computer.

> mkdir ~/myPhone
> jmtpfs ~/myPhone
> ls myPhone
  Internal storage/

At the end, in order to unmount your smartphone filesystem from your computer, you need to issue another command:

> fusermount -u ~/myPhone

This should unmount your smartphone’s filesystem safely without corrupting any part of the filesystem on your smartphone.

Categories
HARDWARE TUTORIALS

What Is USB Type C? Explained In Simple Terms

USB Type C aka USB-C is a new type of USB connector that is getting popular these days in both smartphones and laptops for their high transfer speeds and easy connectivity (You can connect it in any direction you want and it will still work!). In this article, we will try to explain to you what a USB Type C connector and cable is and why everyone are moving to them.

USB-C is a set of new form of USB connectors that comes in two forms namely:

USB Type C Receptacle

USB Type C Receptacle

and

USB Type C Plug

USB Type C Plug

Usually, the USB-C Receptacles are found in devices such as laptops while USB-C Plugs are found in smartphones. We will then use a USB Type C cable to connect our smartphone to the laptop.

Why do we need to use a USB-C over micro-USB?

A USB device such as a USB mouse, USB keyboard, USB Pen drives etc all talk to our computers or smartphones using a special language called USB protocol. This USB protocol is designed by an organization called USB Implementers Forum or USB IF for short.

The USB protocol has been evolving over the years and its latest protocol was designed and revealed by USB IF recently. This new protocol called USB 3.0 has increased the speed at which data gets transferred between the computer and USB devices (like smartphones, USB stick) from 480 Mbps in the earlier USB 2.0 specification to 5 Gbps in USB 3.0 specification! This is a huge increase in speed of data transfer between the devices and hence using USB 3.0 was a major upgrade over USB 2.0

USB Type-C is a new type of USB connector that was released almost at the same time as when the new USB 3.0 specification was released. So almost all the USB device manufacturers who wanted to use USB 3.0 specification also adopted USB Type-C connector instead of the usual micro USB connectors used with USB 2.0

Hence, USB-C connector has recently become synonymous to USB 3.0, although you will still be able to find devices with USB-C connector still following USB 2.0 specification.

This has also given raise to a myriad of problems and confusions in terms of choosing the appropriate USB 3.0 cables which we will address and explain how to identify them in the future articles.

How exactly is USB 3.0 connector different from micro USB connector?

A simple micro USB connector which we have all been using all these years simply had 5 pins within itself where two pins were used to power the device (Vcc, Gnd), two more pins where used to transfer the data (D+ and D-) and a final pin was used to detect the device type (Mode Detect).

However, in case of a USB Type-C connector, we have 24 pins in total, each of which had a unique role to play in the data exchange and charging of devices. So in simple terms, USB Type-C connector increased the pin numbers within each connector from 5 pins earlier in micro USB to 24 pins now in USB Type-C connector!

In the upcoming articles, we will go in detail to understand how USB 3.0 protocol works with the new USB-C or USB Type-C connector and how it achieves the extra-ordinary speed of 5 Gbps data transfers, but for now, this should give you enough idea on the USB-C connector type and its difference from the earlier micro USB connector.

Categories
Android SMARTPHONES TUTORIALS

Motorola One Macro Launched, Priced At Rs.9999

Motorola has officially launched its next Android smartphone in its Motorola One series called the Motorola One Macro. Motorola One Macro is priced at Rs.9999 and will be available for purchase from its official online partner Flipkart website and app from October 12, 2019.

Motorola One Macro

Motorola One Macro is yet another Android smartphone from Motorola focusing primarily on its camera functionality just like its predecessors Motorola One Action & Motorola One Vision.

Motorola One Macro specializes and differentiates itself from other smartphones by utilizing a seperate Macro camera sensor that helps in capturing natural photos at close ups to reveal hidden details that are not normally captured by other camera sensors.

Motorola One Macro also comes with a 6.2 inches Max Vision display, 4 GB RAM, 64 GB Built In Internal Storage with memory card support that can expand the internal storage by adding SD Card support of upto 512 GB.

Motorola One Macro is powered by a Octa Core Mediatek Helio P70 microprocessor which is fabricated using 12 nm technology. On the GPU front, Motorola One Macro is GPU powered by 900MHz Mali GPU designed by ARM.

Motorola One Macro also supports Hybrid nano Dual SIMs where one of the SIM slot will be shared with a micro SD Card, so you will only be able to use SIM or a micro SD Card in that hybrid SIM/SD Card slot.

On the Operating System (OS) front, Motorola One Macro runs on Android 9 Pie, however despite its name and being in the Motorola One series where other smartphones ran on Android One OS, this Motorola One Macro does not run on an Android One.

Speaking of the camera, Motorola One Macro boasts a 13 MP rear camera with f/2.0 aperture and LED Flash support, a 2 MP Macro camera sensor and another 2 MP depth sensor for portrait captures. The front selfie camera boasts a 8 MP sensor with f/2.2 aperture at 1.12Ξm pixel size.

In addition to this, the Motorola One Macro comes with various standard sensors such as accelerometer, gyroscope, proximity sensor along with finger print sensor which is becoming quite common these days.

On the Audio front, Motorola One Macro provides support for 3.5mm audio jack, mono speaker with dolby surround sound and adds support for FM Radio.

Talking about the battery, Motorola One Macro comes with a 4000 mAh battery, which when compared with the previous launch of Motorola One Action which supported only 3500 mAh battery, is much better here. The charging rate is still at 10W.

The Motorola One Macro is not exactly water resitant, but with its IPX2 rating, this Android smartphone is for sure splash resistant like its predecessors.

On the wireless side, Motorola One Macro supports the standard Dual 4G VoLTE, WiFi 802.11 b/g/n, Bluetooth 4.2, GPS, GLONASS and comes with support of USB Type-C connector.

All in all, the Motorola One Macro Android smartphone sure looks like a smartphone that is quite good for its price tag of just Rs.9,999 and if you are a photo enthusiast and particularly into Macro photography, then Motorola One Macro Android smartphone is something that you would love to keep in your pocket for those sudden opportunities that arises where you can go for Macro photography without having to run around to fetch your dedicated macro photography camera.

Categories
TUTORIALS VPS WEB DEVELOPMENT

Tutorial – Setting up a Ubuntu 16.04 VPS Instance on Vultr

In this article, we will learn about how to create a simple Virtual Private Server (VPS) running 64-bit Ubuntu 16.04 Operating System.

In case you have not created an account yet on Vultr, you can do so by visiting the link in the next paragraph and get $50 worth FREE CREDITS that you can use to create and use your Vultr Ubuntu VPS instances

Get Vultr VPS Worth $50 FOR FREE If you too would like to use Vultr VPS instance (which I strongly advise) while following these tutorial series, you can use the following Link to create your Vultr account and get $50 Free Credit which is more than sufficient to use and learn all about Linux, Web Development and much more for FREE!

Once you have created your Vultr account using the link above, you log into your Vultr account by visiting the Vultr Web App. Once you have logged in, you should be in the Products tab which would list all the Vultr instances you have created until now. Since your Vultr account is new, you will not have any instances listed there.

Vultr Dashboard displaying list of active Vultr instances created until now.
Vultr Dashboard displaying list of active Vultr instances created until now

But do not worry, this is about to change now.

Create a new Vultr VPS by clicking on the link that read “deploy now” at the end of that Vultr dashboard web page. You will then be taken to a new web page as shown below:

Vultr Deployment screen where new VPS instance can be created and deployed.
Vultr Deployment screen where new VPS instance can be created and deployed

Do not get perplexed by such a long web page with numerous options. While they may look baffling at first, it is actually pretty easy to use to create your first Vultr VPS instance. We will go through each of these options in a step by step fashion so that it is easier for you to follow and replicate.

Step 1 – Choose Server: Vultr not just provides services to deploy a VPS server, but also many more other products including Bare Metal Machine, Dedicated Cloud etc. However, in our case, we are only interested in deploying a simple VPS server running 64-bit Ubuntu 16.04 OS. Hence, we will simply choose “Cloud Compute” option which is what creates a VPS server.

Step 2 – Server Location: Next, we need to select where we want our VPS server to reside at. Vultr has its data centers spread across the globe and hence we have option to choose our VPS servers from various cities across the world as listed in the option. Choose the one which is closest to your and your web app’s visitors location is. This is because you will get a quick turn around time (time taken by the server’s response to be received) from your server if it is closest to your own location.

Step 3 – Server Type: In this option, we need to choose the type of Operating System (OS) we need to use. If for example we want to install 64-bit Ubuntu 16.04 OS, we select it over here.

Step 4 – Server Size: Next comes the size of the VPS server you want to deploy. This depends on a number of factors such as the amount of data size your app is going to use, the amount of traffic it gets, the speed of the CPU and the number of cores it holds etc. For tutorials and experiments, I usually just use the default selection of $10 per month VPS instance which gives comfortable performance for my requirements.

Step 5 – Additional Features: These are some advanced options which are not selected by default. These includes option to select IPV6 network addresses, backups etc. which I usually leave at its default unchecked state (in other words, I do not use it).

Step 6 – Startup Scripts: This option is useful if you need to run any additional scripts at the startup of your VPS instance. I have never used it until now so I may not be the right person to comment much about it! Sorry!! 😛

Step 7 – SSH Keys: SSH keys are special software keys that are used to create a secured shell protocol connection between your laptop/computer to your Vultr VPS server. In this option, you can generate SSH keys (using this tutorial) for your laptop and take the public part of the SSH keys and paste it here on the Vultr dashboard under this option. This way, you would not need to type in login and password every time you want to connect to your Vultr VPS server from your laptop’s command prompt.

Step 8 – Server Hostname & Label: Finally, you can create a new Hostname and label for your VPS server. This will result in the Vultr dashboard displaying this instance of the VPS server using this Hostname & Label.

Once you are done with filling up with all the above details in your Vultr dashboard, you can click on the “Deploy Now” button to create and deploy your Vultr VPS server. It may take a few minutes since clicking on the button after which your Vultr VPS server should be ready for use!

Hope this article gave you an insight into how to create and deploy a new Vultr VPS instance using Vultr dashboard. If you have any queries or any feedback on this article, do let me know in the comments below. Until next time, happy coding! 🙂

Categories
SMARTPHONES

Why Does Your Smartphone Not Fast Charge When Using Any USB Cable

Fast charging of smartphone batteries are a new and must needed feature these days, especially with Android devices supporting it effectively across all variants of smartphones and tablets. Most of the smartphone supports less than 30 minutes of charging sufficient to reach over 75% of battery charge.

How does a smartphone charge so quickly?

Most of these Android smartphones that support this fast charging feature in them makes it possible by using a proprietary USB fast charging technology. These proprietary fast charging technologies while helps in improving the charge time, but because of their proprietary nature, works well only when you use their provided USB chargers and cables. So, as a result if you try to use a different USB charger or a USB cable, the charging time would go slow again, thereby making you lose all the advantages of fast charging capabilities.

Is USB Fast Charging Not Standardized For Smartphones?

This begs the question as to why we are going for a proprietary USB fast charging technologies that limits its usage to only its own USB fast chargers and USB cables. Can’t this not be standardized in such a way that they can be made to work with all USB chargers and USB cables used with our smartphones?

The answer is yes. We do have a USB fast charging capability built into the USB C standards, covered under the category USB Power Delivery (or USB PD for short). This standard states that all smartphones and similar handheld devices such as Android tablets that comes built with USB Type C connectors and cables need to meet and support the USB Power Delivery (USB PD) specification.

The USB Power Delivery specification states that these smartphone/tablet or other handheld devices need to be capable of delivering upto 100W of power.

However, even then, many Android Original Equipment Manufacturers (OEMs) still do not support this USB C Power Delivery (USB PD) specification and still continue to use proprietary USB fast charging technologies.

But recently, Google is coming down hard on these OEMs and trying to enforce USB PD support for all the Android devices manufactured by them, atleast from Android 10 onwards. This, when achieved, should eventually make all Proprietary USB Fast charging technologies redundant and bring in the USB Power Delivery (USB PD) as the industry standard for USB fast charging technology.

When this happen, we will finally be able to move out of proprietary USB Fast charging technologies and be free to use any USB chargers with any USB cables to charge our Android smartphones and tablets and still be able to enjoy the USB fast charging functionality.

Until then, we will have to make do with the warning messages on our smartphone devices that reads “Device charging slowly use original charger” when connected with non original USB chargers and USB cables. 🙁

Categories
SMARTPHONES

Motorola One Macro Specification Revealed, To Launch On Oct 9 2019

Motorola One Macro Android smartphone is set to be launched on Flipkart this October 9, 2019. Motorola One Macro is yet another smartphone lined up along the Motorola One series, the Motorola smartphone series running on the Android One platform.

Motorola One Macro smartphone is said to boast a separate camera on its rear side that would be used specifically to capture Macro photography. Macro photography is a style of photography where in the photographer would capture a subject at extreme close up, there by revealing extremely detailed picture of the subject. Macro photography style is very popular in nature photography where one would take and expose a detailed picture of natural subjects such as flowers, leaves, trees, hives etc.

With Motorola One Macro smartphone, now the photographers will be able to achieve this even when they are not carrying their specialized camera equipment everywhere there go but yet have an urge to take macro photographs as and when the opportunity arises.

In order to achieve support for Macro photographs, Motorola One Macro smartphone is expected to feature a dedicated macro photographic camera sensor somewhere around 2 MP in resolution along with its standard 13 MP camera sensor and another 2 MP depth camera sensors, as usually found in all other Motorola One series of smartphones such as Motorola Vision, Motorola Action & Motorola Power.

While Macro photographic camera would be the main highlight of Motorola One Macro smartphone, it is also expected to boast a good 4000 mAh battery for a full day battery performance, a 6 inch plus LCD display and is also expected to run on a Mediatek processor, possibly Helio P60.

On the front camera side, the Motorola One Macro phone is also expected to carry a good high camera with a resolution as high as 8 MP.

As with the recently launched Motorola One Action smartphone in August 2019, the current Motorola One Macro smartphone is also expected to run on Android 9 Pie Operating System.

The Motorola One Macro smartphone is also expected to boast a tear drop type of notch, although we do not have many details to verify this.

The teaser page of Motorola One Macro smartphone is already up on the Flipkart e-commerce website which boasts some interesting features such as magnified details thanks to the Motorola One Macro’s Macro camera sensor, maximized speed for a quick capture even under challenging lighting conditions (read low lighting conditions), rapid charging, highly multitasking capable smartphone and more.

We will further keep you updated on the Motorola One Macro smartphone as soon as we get any further information. Until then, happy shopping!

Categories
100DaysOfCode PROGRAMMING TUTORIALS

How To Write Code Like A Professional?

Everyday, we programmers write hundreds of lines of programming code. But, have you ever stopped to notice if your program is good enough? How do you make sure your programming skill set is up to the mark? How to make sure you are Programming Like A Pro? In this article, we consider these questions and try to answer them each in greater details.

How To Code Like A Pro?

There are many characteristics of a program written by an experienced professional that sets his code apart from a code newbie. A professional programmer would make use of his past learning experience and implement his code that follows a certain set of guidelines and best practices he has learnt over the time since he began programming.

While each of these set of guidelines and best practices may differ from one Professional Programmer to another Pro, there are many common guidelines which more or less all Professional Programmers follow that can make their code set apart from the rest. Here is a list of some of such common guidelines used by almost all Professional Programmers. If you can practice and incorporate these practices and techniques into your daily programming routine, even your program code will start to look more professional.

Best Practices & Guidelines To Write Code Like A Professional

  • Write code that makes use of the processor efficiently – In other words, write code that runs fast on the processor using lower number of clock cycles. How to achieve this? While there are many things involved in learning to write a highly CPU efficient programs which will be explained in the future articles, some of the most common practices is to use loops sparingly, use efficient looping systems, write programs using instructions that require less clock cycles to accomplish the task at hand etc. You need to have good understanding of the underlying computer system architecture to get a better hold or control on these aspects, so learn more about the computer architecture.
  • Write code that makes use of memory efficiently – Use the memory of a computer system efficiently and sparingly. It usually takes certain amount of computer clock cycles to read and write data to or from the memory. So if you want your code to speed up, it is better to write code using instructions that uses lesser amount of memory. If your code allocates too many variables, it can start gobbling up a lot of RAM space in your user’s computer, there by slowing down the computer all together, thus giving a had user experience.
  • Write code that is more readable – This is one of the most important aspect of a professional code. You can write code in a convoluted way to do something extremely smart on its data, but if in the future you move on in your job role and your code is handed over to your junior developers, they will find it extremely hard to read and understand your code. So always write code that is easily readable by anyone familiar with programming. This can also include adding more comments in your source code, naming the variables appropriately etc. Sometimes, writing readable code could result in writing a slightly inefficient piece of code thus contradicting the above 2 points discussed earlier. But however, in such a situation, it is still advisable to give priority towards readable code than saving a few CPU clock cycles.
  • Write code that is highly modular – What does this mean? It means you need to break down your programming into individual modules such as functions and classes, that does one thing and only one thing but extremely well. Your code need to be split up into several functions, files and libraries that can be made use of in the future for other projects as well.
  • Write code that is well tested and documented – Each of your code modules need to be very well tested to ensure it fulfills and works under all boundary conditions. It should not break down for some unexpected values but gracefully reject the input under such situations. This is achieved by writing robust test cases that can test for all frequently possible conditions even if it occur only one in a million time (boundary conditions). Make sure that the code is well documented using comments and appropriate variable or function names as discussed earlier.
  • Write code that is easy to enhance – Before you sit down to write your code, you need to design to program to be highly modular and easy to enhance of its functionalities in the future. This would mean writing code that is modular, with will defined APIs and interfaces such that a function serving that API can be swapped for another function with a different implementation for the same set of input and output values.

There are still many more aspects of a professional’s code that usually depends on his style and taste of coding, but the above list should give you a good fundamental beginning on how to think and write code like a professional programmer.

In the future articles, we will continue to explore some of the fundamental aspects of computer science such as a computer’s architecture, its basic functionality etc that will help us getting a solid understanding the basics of computer science. Do let me know if you have any comments on this or any other topic you would want me to explore and I will be happy to accommodate your requests.

So until then, happy coding! 🙂