Main Site Documentation

Portrait Display


#1

Hi,
Wondering if somebody could point me in the right direction.

I’ve been trying to change the orientation mode of my T35 display to portrait.

When I try.


GHIElectronics.NETMF.Hardware.Configuration.LCD.SetRotation(GHIElectronics.NETMF.Hardware.Configuration.LCD.Rotation.Rotate_CW_90);

the screen goes blank.

I think I may have to also set the height and width but I’m not quite sure how.

Thanks


#2

I am not sure what would happen when you test this through gadgeteer core as this may not be supported.

Try doing this with a simple application with you gadgeteer code first.


#3

Hi,

Simplest possibe gadgeteer application. Text is displayed with Rotate_Normal or Rotate_180 but not with Rotate_CW_90 or (I suspect) with Rotate_CCW_90


Debug.Print("Program Started");
            GHIElectronics.NETMF.Hardware.Configuration.LCD.SetRotation(GHIElectronics.NETMF.Hardware.Configuration.LCD.Rotation.Rotate_180);

            display.SimpleGraphics.DisplayTextInRectangle("testing", 20, 20, 100, 100, Color.White, Resources.GetFont(Resources.FontResources.NinaB));

Regards,

David Cowan


#4

In the original post I said the screen went blank, actually it is not updated.


#5

Are you updating your bitmap with the new dimensions 240x320 instead of 320x240?


#6

Hi,

I suspected that I needed to do this but wasn’t sure how (see first post). Any direction welcome.

It may be I need to start to move away from the gadgeteer into just the straight EMX libraries.

Regards,


#7

Know this is moving away from gaqdgeteer. This is an example program of yours.

It sets upo the display for a full vga display. I’m sure I could modify it for a smaller display or do yopu have an example of a 3.5 binch but how would I tell it the display was portrait.


#8

You only need to call the rotate method.


#9

Located at the start of the SetLCDConfigurations() fu8nction???


#10

The one in very first post.


#11

Yes, but where do I put it. Should I set up the basic display first or rotate it first??


#12

Here is a simple example using Gadgeteer. Only modules you will need are the display and button.

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

// Add this assembly to the references
using GHIElectronics.NETMF.Hardware;

///////////////////////////////////////////////////
// Modules attached:                             //
//  -Display T35 on sockets 10, 12, 13, 14       //
//  -Button on socket 8                          //
///////////////////////////////////////////////////

namespace Gadgeteer_Rotate_Screen_Example
{
    public partial class Program
    {
        // Bitmap for when the screen is rotated 0 or 180 degrees.
        public static Bitmap LCD_Landscape = new Bitmap(320, 240);
        
        // Bitmap for when the screen is rotated 90 or 270 degrees.
        public static Bitmap LCD_Portrait = new Bitmap(240, 320);

        // Used to determine which bitmap to use.
        public static bool LCD_Use_Landscape_Rotation = true;

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            /*******************************************************************************************
            Modules added in the Program.gadgeteer designer view are used by typing 
            their name followed by a period, e.g.  button.  or  camera.
            
            Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
                button.ButtonPressed +=<tab><tab>
            
            If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
                GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
                timer.Tick +=<tab><tab>
                timer.Start();
            *******************************************************************************************/
            display.SimpleGraphics.AutoRedraw = true;

            display.WPFWindow.TouchDown += new Microsoft.SPOT.Input.TouchEventHandler(WPFWindow_TouchDown);
            button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);

            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");
        }

        void button_ButtonPressed(Button sender, Button.ButtonState state)
        {
            // Swap between using the Landscape and Portrait
            LCD_Use_Landscape_Rotation = !LCD_Use_Landscape_Rotation;
        }

        void WPFWindow_TouchDown(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
        {
            // Clear both bitmaps.
            LCD_Landscape.Clear();
            LCD_Portrait.Clear();

            // Hold on to our touch position to make the following lines more clear.
            int x = e.Touches[0].X;
            int y = e.Touches[0].Y;

            // If the screen is rotated 0 or 180 degrees...
            if (LCD_Use_Landscape_Rotation)
            {
                // Tell the screen to rotate...
                GHIElectronics.NETMF.Hardware.Configuration.LCD.SetRotation(Configuration.LCD.Rotation.Rotate_Normal);

                // Draw to the correct bitmap...
                LCD_Landscape.DrawText("(X: " + x + " Y: " + y + ")", Resources.GetFont(Resources.FontResources.NinaB), Color.White, x, y);

                // And draw it to the screen
                LCD_Landscape.Flush();
            }
            // If the screen is rotated 90 or 270 degrees...
            else
            {
                // Tell the screen to rotate...
                GHIElectronics.NETMF.Hardware.Configuration.LCD.SetRotation(Configuration.LCD.Rotation.Rotate_CW_90);

                // Draw to the correct bitmap...
                LCD_Portrait.DrawText("(X: " + x + " Y: " + y + ")", Resources.GetFont(Resources.FontResources.NinaB), Color.White, x, y);

                // And draw it to the screen
                LCD_Portrait.Flush();
            }
        }
    }
}


#13

Thanks for that, Clear simple well commented and it worked first time. Just how example code should be.

Now for the next stage. Your example relates to bitmaps. I’ve made really good progress with Skewworks .netclix which uses forms. How do I link the .net clix forms to the bitmaps in your example.


            display.SimpleGraphics.AutoRedraw = true;
            LCD_Use_Landscape_Rotation = false;
            GHIElectronics.NETMF.Hardware.Configuration.LCD.SetRotation(Configuration.LCD.Rotation.Rotate_CW_90);
            Debug.Print("Program Started");



            frmMain = new Form(Skewworks.NETClix.Colors.DarkGray);
            frmMain.Font = Fonts.Verdana10;

            MenuStrip ms = new MenuStrip();
            MenuItem miView = new MenuItem("Main Screen");
            ms.Add(miView);
            frmMain.AddChild(ms);
            Graphics.ActiveContainer = frmMain;


Doesn’t work!! Any thoughts